On Monday, June 1, 2015 at 1:28:53 PM UTC+5:30, Laura Creighton wrote: > If you are giving a talk about Decimal -- and trying to stamp out the > inappropriate use of floats you have to first inform people that > what they learned as 'decimals' as children was not floating point, > despite the fact that we write them the same way. > > If I ever get the time machine, I am going back in time and demand that > floating point numbers be expressed as 12345:678 instead of 12345.678 > because it would save so much trouble. Never has the adage 'It's not > what you don't know, that bites you. It's what you know that ain't so.' > been more apt. > > I have done much better in speaking about this topic to a bunch of > incredulous people if you next explain that scientists really don't > care about accuracy in their calculations. (This will surprise them). > Most scentific calculations have some real world measurement in them, > and for most real world measurements, if you are getting even 5 digits > of precision, you are doing really, really, well. This means that > scientists are going to be throwing away all the extra digits they get > out a a floating point representation, so they don't have to care how > accurate they are. As long as their results are good in the first 5, > it won't matter. (Depending on time constraints, a review of > significant figures -- what they are and what they mean is good here.) > > It is really hard to get the concept of Decimal across to people who > already have that concept in their mind, but think it is called Float. > You have to first teach them that they don't know anything about Float > and get them to reboot their brains before you can install this new > knowledge. Otherwise their brains will just overwrite your new knowledge > with 'ah, just use a Float' as soon as you stop speaking. Same day, > even. > > Laura
I'd say on the whole this *intention* is rightly directed. Whether it would work in practice I am not sure. You may like to look at haskell's defaulting mechanism which is about as sophisticated as I have seen https://www.haskell.org/tutorial/numbers.html [sect 10.4] Basically: (the ':t' says give me the type of...) Prelude> :t 4 4 :: Num a => a Prelude> :t 1.0 1.0 :: Fractional a => a What this says is that 4 is not an integer but any type that is in the Num class Likewise 1.0 is not float but any of a family of 'Fractional' types. Your ':' suggestion would work if Decimal and machine floats covered all needs. Do you think that is possible/likely? If not we would have to fall back to some 'defaulting' mechanism anyway. [In all fairness while Haskell's default looks neat on paper it turns out to be quite a nuisance in practice] -- https://mail.python.org/mailman/listinfo/python-list