Prev: Possible easy diagnostic outputting from multiple threads tothe one text frame
Next: JDK 1.6.0_21 released
From: Kevin McMurtrie on 9 Jul 2010 01:06 In article <4c350cb7$0$282$14726298(a)news.sunsite.dk>, Arne Vajh�j <arne(a)vajhoej.dk> wrote: > On 07-07-2010 14:13, Lew wrote: > > The reason that computer programmers command such good wages is that > > it is a *skilled* profession. Most people cannot do it, and of those > > who can it requires intelligence, study and practice, i.e., it > > requires tremendous intellectual effort and capacity. > > Why can I hear violins in the background? > > :-) > > > It is one of the most fundamental and introductory aspects of computer > > programming that floating-point "numbers" in a computer are limited- > > precision approximations of real numbers. > > There are actually programmers that are never exposed to floating > point. > > Arne Paid programmers? Computer science is knowing how information from the real world can be represented within the constraints of a computer. It's the basis for knowing what you're doing while programming. -- I won't see Google Groups replies because I must filter them as spam
From: blmblm on 9 Jul 2010 07:49 In article <IgaZn.49559$cJ6.6365(a)hurricane>, Boris Punk <khgfhf(a)hmjggg.com> wrote: > > "Arne Vajh�j" <arne(a)vajhoej.dk> wrote in message > news:4c350cb7$0$282$14726298(a)news.sunsite.dk... > > On 07-07-2010 14:13, Lew wrote: [ snip ] > >> It is one of the most fundamental and introductory aspects of computer > >> programming that floating-point "numbers" in a computer are limited- > >> precision approximations of real numbers. > > > > There are actually programmers that are never exposed to floating > > point. [ snip ] > I did plenty of manual sums of floating point numbers at college on paper - > just wanted a refresher from some knowlegeable folk on how it's applied in > java. When you were doing those manual sums, was part of the problem specification how many digits of precision would be kept? I guess I'm genuinely curious about whether you just didn't remember that floating-point quantities have limited precision [*], or you remembered that but somehow thought the Java "double" primitive type might be different, or what. [*] Now that I think about it, I'm uncertain about whether that's inherent in a definition of "floating point" -- the definition used in the Wikipedia article on "floating point" seems to imply fixed size, but to me that doesn't seem to be inherent in the idea of "binary representation of scientific notation", though it might be more difficult to build hardware that could operate on floating-point quantities of arbitrary size. > Is Lew on a period or something? Hehe get it...period...never mind.... Clever wordplay, in its way, but I'd advise against jokes that rely on gender stereotypes, unless you know more about your audience than I think you do here. -- B. L. Massingill ObDisclaimer: I don't speak for my employers; they return the favor.
From: Martin Gregorie on 9 Jul 2010 14:53 On Thu, 08 Jul 2010 16:18:55 -0600, Jim Janney wrote: > Tom Anderson <twic(a)urchin.earth.li> writes: > >> On Thu, 8 Jul 2010, Martin Gregorie wrote: >> >>> On Wed, 07 Jul 2010 21:32:30 -0400, Lew wrote: >>> >>>> Lew wrote: >>>>>> It is one of the most fundamental and introductory aspects of >>>>>> computer programming that floating-point "numbers" in a computer >>>>>> are limited- precision approximations of real numbers. >>>> >>>> Arne Vajh?j wrote: >>>>> There are actually programmers that are never exposed to floating >>>>> point. >>>> >>>> Then a) they aren't programmers and b) they are derelict if they wish >>>> to be. >>> >>> Depends what they're doing, e.g. if they're writing financial software >>> in COBOL or RPG 3, its quite likely that they may never need use >>> floating point in their entire working life: by default COBOL does >>> fixed decimal point arithmetic which is more appropriate for financial >>> calculations than floating point because the answer is always exact. >> >> Exact, although not necessarily correct! > > Financial calculations, especially ones involving interest rates, often > use values that are expressed as decimal fractions, 0.01, 0.03, etc. > These can be represented exactly in fixed or floating decimal, but > usually not in binary. 0.125 can, but it's an exception. > > Every so often I have a go at trying to explain this to my coworkers, so > far without much success. Actually, I've yet to see a financial package that used anything but integers for currency amounts, so in USD or GBP the amounts would be cents and pence respectively the decimal point is just interpolated when the value is displayed, e.g. in COBOL: 01 AMOUNT COMP SYNC PIC S9(9). 01 DISP_AMOUNT PIC -Z,ZZZ,ZZ9.99 BLANK WHEN ZERO. MOVE 150 TO AMOUNT. ...... MOVE AMOUNT TO DISP-AMOUNT. would output the amount, $1.50 held internally as 150 cents, as " 1.50" Interest and exchange rates, etc. is quite another matter: whether they are held internally as fixed point decimal or floating point is entirely up to the system designer and the compiler writer. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
From: Martin Gregorie on 9 Jul 2010 14:59 On Thu, 08 Jul 2010 20:03:44 -0400, Arne Vajhøj wrote: > You may find more experience with it in the other sciences: physics, > astronomy, statistics, econometrics etc.. > I'm glad you said *may* as I remember meeting an actuary, no less, who insisted on calculating standard deviations on samples containing less than 10 values. When, as a rather junior programmer but one with an MSc, I queried this I got slapped down by said actuary. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
From: Jim Janney on 9 Jul 2010 18:05
Martin Gregorie <martin(a)address-in-sig.invalid> writes: > On Thu, 08 Jul 2010 16:18:55 -0600, Jim Janney wrote: > >> Tom Anderson <twic(a)urchin.earth.li> writes: >> >>> On Thu, 8 Jul 2010, Martin Gregorie wrote: >>> >>>> On Wed, 07 Jul 2010 21:32:30 -0400, Lew wrote: >>>> >>>>> Lew wrote: >>>>>>> It is one of the most fundamental and introductory aspects of >>>>>>> computer programming that floating-point "numbers" in a computer >>>>>>> are limited- precision approximations of real numbers. >>>>> >>>>> Arne Vajh?j wrote: >>>>>> There are actually programmers that are never exposed to floating >>>>>> point. >>>>> >>>>> Then a) they aren't programmers and b) they are derelict if they wish >>>>> to be. >>>> >>>> Depends what they're doing, e.g. if they're writing financial software >>>> in COBOL or RPG 3, its quite likely that they may never need use >>>> floating point in their entire working life: by default COBOL does >>>> fixed decimal point arithmetic which is more appropriate for financial >>>> calculations than floating point because the answer is always exact. >>> >>> Exact, although not necessarily correct! >> >> Financial calculations, especially ones involving interest rates, often >> use values that are expressed as decimal fractions, 0.01, 0.03, etc. >> These can be represented exactly in fixed or floating decimal, but >> usually not in binary. 0.125 can, but it's an exception. >> >> Every so often I have a go at trying to explain this to my coworkers, so >> far without much success. > > Actually, I've yet to see a financial package that used anything but > integers for currency amounts, so in USD or GBP the amounts would be > cents and pence respectively the decimal point is just interpolated when > the value is displayed, e.g. in COBOL: > > 01 AMOUNT COMP SYNC PIC S9(9). > 01 DISP_AMOUNT PIC -Z,ZZZ,ZZ9.99 BLANK WHEN ZERO. > > MOVE 150 TO AMOUNT. > ..... > MOVE AMOUNT TO DISP-AMOUNT. > > would output the amount, $1.50 held internally as 150 cents, as > " 1.50" > > Interest and exchange rates, etc. is quite another matter: whether they > are held internally as fixed point decimal or floating point is entirely > up to the system designer and the compiler writer. In practice there's a strong tendency toward whatever the programming language makes convenient. The system I work with was originally written in RPG. RPG strongly favors fixed point decimal, and that's what is mostly used in the RPG code and in the data base, for example 9 digits with 2 decimal places for dollar and cent amounts and 5 digits with 5 decimal places for interest rates. In Java we have USD and Percent classes that use BigDecimal internally. Using integers for currency amounts is numerically sound but relies on the programmer to keep track of the decimal position. Not bad for small projects but it would make me nervous for larger projects where there's significant turnover among the programmers. -- Jim Janney |