On Fri, 2008-05-02 at 23:52 -0400, Cristian Rodríguez wrote:
> Todd Ruth escribió:
> 
> > Most people don't care about floating numbers beyond a certain 
> > number of digits.  
> 
> That's the main flaw in your suggestion, "most people".. the language 
> should be correct, do the real right thing.

Would you suggest that the "real right thing" is to
print 100 digits by default?  That argument could be
made, but I think everyone agrees that as a practical
matter, most people don't care about most of the
digits so a default is set for "precision" that
makes most people happy without ever even knowing
the "precision" setting exists.

Why should things be any different for other non-progressing
uses of a float?  (By non-progressing, I mean a use of a float
that doesn't affect digits of another float, such as doing
a comparison or using a float as an array key.)  A
comparison_precision value could be set to 14 by default.
That will make most people happy for most cases without
ever even thinking about it.  If someone wants more digits,
they care enough about floats to likely be aware of such
settings.  (and if they don't they need to be aware of all
these issues and the improvements I'm encouraging wouldn't
help them - not being able to help that small percent isn't
a reason not to help the others)

There seems to be an attitude of "that's what you get for
using floats".  In c, you can't compare strings intuitively
because you'd be comparing addresses not strings.  php
hides that ugly bit of internals, so the programmer can
compare two strings without worrying about all that.  No one
says "That's what you get for using strings; you always need
to make a function call to compare strings."  Why not let the
programmer get intuitive behavior for floats too?  The people
who want to have incredibly small epsilons know their stuff
and would use a vary large value for comparison_precision
(and if they don't know their stuff need to learn it any case).

- Todd

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to