[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Magic numbers

Subject: Re: Magic numbers
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 18 Nov 2003 13:17:24 GMT
magic of numbers

> which works fine and shows the expected result... now...if you change
> .05 for .07 you get something totally unexpected (at least is unexpected
> to me).

It is the result for 0.05 that is more surprising than the result for 0.07.

You wrote your numbers using decimal ".05" or ".07" but most computers
these days are binary machines.

You can not store either of those numbers exactly in base two floating
point, just as you can't store 1/3 in base 10: its 0.333333... as
accurate as you want to be but you can't store it exactly.

So whenever you do floating point arithemetic on a machine you should
_expect_ to see roundoff errors. Sometimes you get lucky and the
roundoff error is smaller than the number of digits output so you get
what looks like an exact answer, but in general this can't happen.


David




________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.