Python is DOOMED! Again!

BartC bc at freeuk.com
Mon Jan 26 18:00:22 CET 2015


[Reposting. First attempt went direct to poster, perhaps via email, not 
sure why as I don't have a button to do that. If this does the same then 
please ignore.]
On 23/01/2015 10:59, Steven D'Aprano wrote:
 > Chris Angelico wrote:
 >
 >> On Fri, Jan 23, 2015 at 1:16 AM, Steven D'Aprano
 >> <steve+comp.lang.python at pearwood.info> wrote:
 >>> Mario Figueiredo wrote:
 >>>
 >>>> def handle_employees(emp: Union[Employee, Sequence[Employee]], raise:
 >>>> Union[float, Sequence[float]]) -> Union[Employee, Sequence[Employee],
 >>>> None]:
 >>>
 >>> Using
 >>> floats for money is Just Wrong and anyone who does so should have their
 >>> licence to program taken away.
 >>
 >> But using a float to specify a percentage raise that an employee (or
 >> class of employees) gets would be reasonable.
 >
 > I don't think that a raise of 0.10000000000000001 (10%),
 > 0.035000000000000003 (3.5%) or 0.070000000000000007 (7%) is quite what
 > people intended.

It seems they are getting a bigger raise than they expected in each 
case. So why complain?

But in practice they will never see that billionth of a cent extra; they 
will get the same amount as they would if floating point wasn't used.

And, how is the increase determined? It could well be the result of some 
complex calculation performed in floating point, which then has to be 
converted to ... BTW how *do* you represent a raise of 10% exactly if 
not with binary floating point?

-- 
Bartc






More information about the Python-list mailing list