Re: Fixed Point Arithmetic



David Cressey wrote:
"Gene Wirchenko" <genew@xxxxxxxx> wrote in message
news:58rn03pspoga5r87b0v632b4tmug00gq7f@xxxxxxxxxx
"David Cressey" <cressey73@xxxxxxxxxxx> wrote:

[snip]

When it comes to the stock market, it depends on the country. AFAIK,
the
NYSE still records stock "points" in units of dollars, with binary
fractional points like 1/4, 1/32, and the like. The use of decimal FPs
with this kind of data will introduce round off problems that would have
been avoided with binary floating point numbers.
Try again. Since 10 is evenly divisible by 2, you simply need
more precision. For example, 1/32 is exactly representable in decimal
as .03125.


Oops. It's my second turn to be embarrassed in just a week.

Don't be too embarrassed. Its true that the various fractions used for some (if not all) US stock quotations are rational there is still scope for your rounding issue to arise. This is because some instruments are quoted in 1/128ths and when settlement amounts are calculated parts of cents can arise depending on the number of lots traded etc. This is of course a trivial event.

Even though, here in Oz, we use decimal quotation depths in the case of Bonds the RBA specification actually describes the exact points where rounding is to be performed to eliminate confusion on the consideration for settlement.

Cheers, Frank.
.



Relevant Pages

  • Re: Rounding errors
    ... >fractions with an arbitrary precision then the average will indeed be ... That's because a fraction will not produce zero. ... After rounding was applied, the sum became 500,500. ... On one report you might say you are ...
    (comp.lang.cobol)
  • Re: Why not FP for Money?
    ... Floating point arithmetic is useful for continuous quantities, ... Rounding issues in floating point revolve around preserving ... over and above trying to use binary fractions in a field ...
    (comp.lang.python)
  • Re: Decimal Display
    ... Rick Rothstein wrote: and number containing fractions BEFORE it performs the Mod operations. ... The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as result. ... Usually, the data type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Variant containing a Long, regardless of whether or not result is a whole number. ...
    (microsoft.public.vb.general.discussion)
  • Re: "bankers rounding"
    ... monetary calculations to be stored as fractions. ... that way to determine precision later. ... You cannot coordinate to give one account the extra $0.0001 because ... rounding error to embezzle money from his employer to build a super evil ...
    (microsoft.public.vb.general.discussion)
  • Re: Decimal Display
    ... and number containing fractions BEFORE it performs the Mod operations. ... The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as result. ... Usually, the data type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Variant containing a Long, regardless of whether or not result is a whole number. ...
    (microsoft.public.vb.general.discussion)