Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.misc > #2673

Re: BASIC is 50

From "BartC" <bc@freeuk.com>
Newsgroups comp.misc
References (1 earlier) <5360da8d$0$17144$c3e8da3$dd9697d2@news.astraweb.com> <ljr6f8$6mn$1@dont-email.me> <53616180$0$59815$c3e8da3$e074e489@news.astraweb.com> <gknav.371282$sa2.196137@fx33.am4> <bsuj7gFd631U1@mid.individual.net>
Subject Re: BASIC is 50
Message-ID <Xtpav.335997$5V5.276603@fx08.am4> (permalink)
Organization virginmedia.com
Date 2014-05-07 13:14 +0100

Show all headers | View raw



"Huge" <Huge@nowhere.much.invalid> wrote in message
news:bsuj7gFd631U1@mid.individual.net...
> On 2014-05-07, BartC <bc@freeuk.com> wrote:
>> "Rich" <rich@example.com> wrote in message
>> news:53616180$0$59815$c3e8da3$e074e489@news.astraweb.com...
>>> Scott Alfter <scott@alfter.diespammersdie.us> wrote:
>>
>>> 99.7099999999999999436561815002733055735006928443908691406250000000000000
>>>
>>> This is why floating point can be dangerous, and why floating point
>>> should _NEVER_ ever be used to compute monetary values:
>>
>> Why not? Because the result might be off by a quadrillionth of a cent?
>>
>> Use rounding properly and it can be made to work (unless you're dealing
>> with
>> very large amounts such as the US debt then it's a bit trickier to avoid
>> errors starting to affect the cents).
>
> Pretty obvious you've never worked in finance or banking.

I've written software that worked with currency. I used floating point. But
not for banking. (In that particular application, it needed to work in two
linked currencies. The conversion rate between them was such that one or the
other would generally always be a fraction of a cent wrong, rounded to the 
nearest cent.)

The only issue that might arise (and I can't remember it happening in my
code), is in rounding a value ending in 0.5 cents or very close, then you
have to decide to round up or down. The result might however have to match
the same calculation done elsewhere, where the rounding might be the other
way because their floating point result is different. (But there are ways of
getting consistent, portable floating point results too.)

(In any case, typical 64-bit floating point can represent amounts up to
nearly $100 trillion, expressed in whole cents.)

-- 
Bartc

 

Back to comp.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

BASIC is 50 Gordon Henderson <gordon+usenet@drogon.net> - 2014-04-30 09:34 +0000
  Re: BASIC is 50 Ant <ant@zimage.comANT> - 2014-04-30 03:42 -0700
    Re: BASIC is 50 Bob Eager <news0002@eager.cx> - 2014-04-30 10:46 +0000
      Re: BASIC is 50 Gordon Henderson <gordon+usenet@drogon.net> - 2014-04-30 12:03 +0000
  Re: BASIC is 50 Rich <rich@example.com> - 2014-04-30 11:12 +0000
    Re: BASIC is 50 scott@alfter.diespammersdie.us (Scott Alfter) - 2014-04-30 15:56 +0000
      Re: BASIC is 50 Rich <rich@example.com> - 2014-04-30 20:41 +0000
        Re: BASIC is 50 Will Honea <whonea@whonea.net> - 2014-04-30 18:38 -0600
          Re: BASIC is 50 Rich <rich@example.com> - 2014-05-01 02:38 +0000
            Re: BASIC is 50 Will Honea <whonea@whonea.net> - 2014-04-30 22:50 -0600
      Re: BASIC is 50 Rich <rich@example.com> - 2014-04-30 20:48 +0000
        Re: BASIC is 50 Richard Kettlewell <rjk@greenend.org.uk> - 2014-05-02 09:27 +0100
          Re: BASIC is 50 Tim Streater <timstreater@greenbee.net> - 2014-05-02 09:50 +0100
        Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-07 10:48 +0100
          Re: BASIC is 50 Tim Streater <timstreater@greenbee.net> - 2014-05-07 10:57 +0100
          Re: BASIC is 50 Huge <Huge@nowhere.much.invalid> - 2014-05-07 11:20 +0000
            Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-07 13:14 +0100
              Re: BASIC is 50 Marko Rauhamaa <marko@pacujo.net> - 2014-05-07 16:05 +0300
                Re: BASIC is 50 Paul Sture <nospam@sture.ch> - 2014-05-08 18:06 +0200
                Re: BASIC is 50 Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 20:17 +0300
              Re: BASIC is 50 "James Harris" <james.harris.1@gmail.com> - 2014-05-07 16:08 +0100
                Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-07 18:38 +0100
                Re: BASIC is 50 "James Harris" <james.harris.1@gmail.com> - 2014-05-07 19:09 +0100
                Re: BASIC is 50 Huge <Huge@nowhere.much.invalid> - 2014-05-07 19:08 +0000
              Re: BASIC is 50 greymausg@mail.com - 2014-05-08 10:15 +0000
                Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-08 11:38 +0100
              Re: BASIC is 50 Paul Sture <nospam@sture.ch> - 2014-05-08 17:55 +0200
          Re: BASIC is 50 Paul Sture <nospam@sture.ch> - 2014-05-08 17:44 +0200
          Re: BASIC is 50 Rich <rich@example.com> - 2014-05-12 12:39 +0000
            Re: BASIC is 50 Marko Rauhamaa <marko@pacujo.net> - 2014-05-12 16:06 +0300
            Re: BASIC is 50 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-05-12 22:48 +0100
              Re: BASIC is 50 Rich <rich@example.com> - 2014-05-13 12:03 +0000
                Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-13 13:23 +0100
                Re: BASIC is 50 Rich <rich@example.com> - 2014-05-13 16:22 +0000
                Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-13 19:42 +0100
                Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-13 19:49 +0100
                Re: BASIC is 50 Rich <rich@example.com> - 2014-05-14 01:09 +0000
                Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-14 09:51 +0100
                Re: BASIC is 50 bde@besplex.bde.org (Bruce Evans) - 2014-05-14 10:36 +0000
                Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-14 12:58 +0100
                Re: BASIC is 50 bde@besplex.bde.org (Bruce Evans) - 2014-05-14 16:13 +0000
                Re: BASIC is 50 "BartC" <bc@freeuk.com> - 2014-05-14 19:24 +0100
                Re: BASIC is 50 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-05-13 15:50 +0100
    Re: BASIC is 50 Johny B Good <johnny-b-good@invalid.ntlworld.com> - 2014-05-01 02:50 +0100
    Re: BASIC is 50 David Hume <David.Hume@example.com> - 2014-05-01 09:06 +0100
      Re: BASIC is 50 Gordon Henderson <gordon+usenet@drogon.net> - 2014-05-01 09:56 +0000
      Re: BASIC is 50 Rich <rich@example.com> - 2014-05-01 10:25 +0000
        Re: BASIC is 50 Marko Rauhamaa <marko@pacujo.net> - 2014-05-01 16:43 +0300
          Re: BASIC is 50 Gordon Henderson <gordon+usenet@drogon.net> - 2014-05-01 18:03 +0000
          Re: BASIC is 50 Bob Eager <news0002@eager.cx> - 2014-05-01 21:35 +0000
        Re: BASIC is 50 Rob <monst.oorzudo@ntlworld.com> - 2014-05-01 22:41 +0100
          Re: BASIC is 50 David Hume <David.Hume@example.com> - 2014-05-02 09:26 +0100
            Re: BASIC is 50 Hils <hils@saynotospam.net> - 2014-05-02 10:46 +0100
            Re: BASIC is 50 Johny B Good <johnny-b-good@invalid.ntlworld.com> - 2014-05-02 23:11 +0100
  Re: BASIC is 50 Anssi Saari <as@sci.fi> - 2014-04-30 17:51 +0300
  Re: BASIC is 50 Peter Percival <peterxpercival@hotmail.com> - 2014-05-14 17:40 +0100

csiph-web