[plt-scheme] Numerical precision
You want to do rounding or truncation according to the requirements of
the simulation. He says that he is doing personal financial
simulations, which implies to me that after each operation the
simulation keeps only a certain precision (like a person would enter
only n digits beyond the decimal in a spreadsheet, or write them from
a calculator display.)
Perhaps not :)
rac
On Mar 11, 2009, at 8:25 PM, Henk Boom wrote:
> 2009/3/11 Richard Cleis <rcleis at mac.com>:
>> You could consider computing everything with integers that
>> represent the
>> precision in your sim. (e.g., $1.23 would be 123 cents or 1230
>> mills or
>> whatever.) After a division or multiply, rounding or truncation can
>> be used
>> to create a new integer with the algorithm that your sim requires.
>> Converting between the sim integers and $nn.nn needs to occur only
>> when you
>> want to display values or accept input.
>
> This does not avoid the associativity problems though, nor the
> problems of accumulation of error. You really want to do rounding only
> when necessary.
>
> Henk
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme