Dan Sugalski wrote:
>At 02:49 PM 8/29/00 -0400, Andy Dougherty wrote:
>>On Tue, 29 Aug 2000, David L. Nicol wrote:
>>
>> > I'd like to see every number bundled with a "precision" attribute.
>>
>>While that might be useful for simple calculations, I expect it would
>>simply get in the way and slow things down for larger, more complex
>>calculations.
>
>It'd also tend to freak people out when this:
[...]
>printed out 6. You think we have bug reports from floating point issues now...
Okay, brainstorming here ... bear with me.
What if limit-of-error precision were tracked, as Perl tracks tainted
variables when you tell it to?
It'd have to be more than a single bit, which I believe is all that's
stored for taintedness.
Instead of Perl horning in on your calculations, as in Dan's example
above, you'd have the ability to query the precision of results.
$one = 25; # Integer. Infinite precision. Or at least, 32 bits.
$two = $one/7; # Float. Precision is reduced to your mantissa.
$thr = $two * $two; # Still less precision. I don't know the math.
print $thr; # Prints 12.7551020408163
print precision ($thr); # Tells you how much to trust $thr
Perhaps it would be a read/write value, so you could tell it that a
raw number had only so many bits of precision.
$four = 74.5;
precision($four) = 7; # Only 7 mantissa bits of accuracy here.
This would be a feature, like taint, that would only be turned on when
the programmer explicitly asked for it, as I expect it would slow things
down somewhat, and would not be used by many people. Mostly scientific
and maybe financial people, I'd think.
use precision; # maybe?
Disclaimer: I failed limit-of-error analysis in college :-)
----------------------------------------------------------------------
Eric J. Roode, [EMAIL PROTECTED] print scalar reverse sort
Senior Software Engineer 'tona ', 'reh', 'ekca', 'lre',
Myxa Corporation '.r', 'h ', 'uj', 'p ', 'ts';