Re: Working with floating point values



That's what I've always done in the past, but decimals are *much* slower to
process than floating-points. In this project, I'm running some fairly
complex calculations thousands of times each, so the difference between
decimals and doubles is quite noticeable. So, I'm pretty much stuck with
doubles.

"Brian Delahunty" <BrianDelahunty@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:FA9D9644-D546-455B-8FD3-225951914CE3@xxxxxxxxxxxxxxxx
> Just use Decimal.
> --
> Brian Delahunty
> Ireland
>
> http://briandela.com/blog
>
>
> "David Veeneman" wrote:
>
>> I'm working on a project that uses floating-point values (doubles), and
>> I'm
>> being driven crazy by something pretty basic. I understand that it's in
>> the
>> nature of floating-point calculations to produce values like
>> 0.10000000000000003, when what I really want is 0.1. But is there any way
>> to
>> eliminate that digit at the end? I've tried rounding, but that simply
>> moves
>> the digit to the least significant position, such as 0.1000003.
>>
>> Failing that, can anyone recommend any good online articles for dealing
>> with
>> floating-point issues, beyond using Epsilon for zero comparisons? Thanks
>> in
>> advance.
>>
>> David Veeneman
>> Foresight Systems
>>
>>
>>


.



Relevant Pages

  • Re: Excel is unusable for finance or accounting.
    ... The problem isn't really in the floating-point representation of numbers, per se, or the ... Could Exel do floating-point ... The processor can't do decimal math natively, so it'd have to be done in software, ... handle simple fractions and decimals (see thread 'Glaring Excel calc ...
    (microsoft.public.excel)
  • Re: A wrong calculation by excel
    ... This so-called error is the result of the computer converting decimals ... Floating-point arithmetic may give inaccurate results in Excel ... Tutorial to Understand IEEE Floating-Point Errors ...
    (microsoft.public.excel.misc)
  • Re: Gentler Decimal Floating-Point
    ... decimal FLOATING-POINT arithmetic and, despite frequent requests, you ... financial programmers wanted fixed-point with overflow detection, ... NONE of them wanted decimal floating-point. ... |> migrated towards floating-point for decimals. ...
    (comp.arch.arithmetic)
  • Re: strings (dollar.cents) into floats
    ... But what use is there for floats, ... cannot be exactly represented by decimals. ... Indeed I believe the accountant's Swiss army knife, the Excel spreadsheet, uses floating-point numbers exclusively. ... What you say about floating-point have speed advantages is true, but you go too far in claiming that decimal arithmetic is mandatory for monetary calculations. ...
    (comp.lang.python)
  • Re: is order urgent doubt
    ... Because double double (using a pair of doubles to represent a single ... floating-point number) in the general case doesn't adhere to the ... to restrict the exponents to make the fraction bits contiguous rather ...
    (comp.lang.c)