in reply to Fixed precision numbers

What are you calculating? Emelda Marcos' shoe budget:)

With accuracy to 15-digits at least, perls floats would handle sums of cash upto around $90 trillion if you maintained the numbers as cents rather than dollars & cents and just divided by 100 for output.


..and remember there are a lot of things monks are supposed to be but lazy is not one of them

Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

Replies are listed 'Best First'.
Re: Re: Fixed precision numbers
by hossman (Prior) on Feb 25, 2003 at 20:55 UTC
    You're making a lot of assumptions about the posters data ... in particular that they are using US Currency. They said "monetary units". They could be dealing with a wide variety of Currencies, which could each have their own scaling factor. They also may be dealing with a billing system that requires them to handle "fractions of a cent"

      I could have said pounds & pence, or yen ??, the principle holds for most currencies I'm familiar with, in that they use 100 minor:1 major unit.

      Granted, if we start talking Yen, you start to loose accuracy in the 100th of a Yen range when totals grow larger than around $750,000,000,000 US dollars equivalent, but that is still larger than the gross national product of most, if not all, countries.

      Also, a quick (read: not thorough) investigation shows that most of the currencies that have high number exchange rates - the Yen, South Korean Won, the Italian Lire (deceased) do not have (or possibly no longer use) any minor denomination for their currancies, which makes inaccuracies 100 times less likely.

      I also didn't make any assumptions, I simply asked the question. I left it to OP to decide whether that was sufficient precision for his/her purpose. It could be that they work for a clearing bank and handle sums large enough that the cumulative totals require greater precision, although they usually use BCD field in COBOL programs for their calculations.

      I only really sought to point out that for most purposes, calculating in pence/cents/other rather than pounds&pence/dollars@cents/other&other allows perls floats to retain accuracy to numbers large enough to total the annual turnover of most companies.


      ..and remember there are a lot of things monks are supposed to be but lazy is not one of them

      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.
Re:x2 Fixed precision numbers
by grinder (Bishop) on Feb 26, 2003 at 18:13 UTC

    Brazil had really ferocious inflation a few years back, and the financial community had tremendous difficulties in dealing with currency values. Basically they ran their computer programs and had to say "ok, this value of 123000 stored here, well really, you have to add 9 zeroes behind it to get the real value". By the time they had managed to fix the systems to represent currency in a meaningful way, inflation had made the figures run away again. (I wish I could find a reference to this story, it makes for fascinating reading from a programming perspective). update i.e. because of inflation, computer programs kept running up against limits of number representations.

    A quick glance at a currency cross-rates page reveals that the current winner is the Turkish lira. You'll need about 1.6 million of them to buy a US dollar, and 1.7 million of them to buy a euro. Even a single lowly japanese yen will set you back about 13.7 thousand lira. And should you wish to acquire an ounce of platinum, better get out your wheelbarrow, because you'll have to muster up 1.1 billion lira.

    Ok, I know, this doesn't mean anything except that Turkish currency must be printed with an awful lot of zeroes, but we're talking about 6-7 orders of magnitude, which makes your capacity to represent $90 trillion melt down to a mere 9 million bucks.


    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

      Which is why they had to withdraw the 10,000 and 5,000 Turkish lira coins from circulation. The metal was worth more than the face value, so people were exchanging larger denominations for smaller ones, melting them down and selling it for scrap value.

      I believe that is is also true that the banks refuse to handle quantites less that 10,000 at a time and simple round them out if they are present in a transaction.

      Quite why they have never simple revalued the denomination 10,000:1 I don't quite understand, maybe all the zeros make them feel rich:)

      BTW. If you've got a mere $9 billion going spare...:)


      ..and remember there are a lot of things monks are supposed to be but lazy is not one of them

      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.