Re: Odd [math] behavior

This WebDNA talk-list message is from

2003


It keeps the original formatting.
numero = 52778
interpreted = N
texte = I cringed when I saw this thread, knowing that it would lead to a discussion of the inaccuracies of binary representation of decimal numbers. I got a kick out of the following quote (taken from one of the links John provided - Thanks, John!). "Floating point is by its nature inexact. It is probably best if you imagined that after every floating point operation, a little demon came in and added or subtracted a tiny number to fuzz the low order bits of your result..." I am sure that even the most experienced programmer has gotten 'bit' by this. So, I think the lesson here is to ALWAYS keep in mind the desired 'precision' when performing floating point arithmetic and use the [format x.xf] to ensure that you get what you expect. FEEDBACK REQUEST: Given that most WebDNA programmers would not expect to have to deal with those 'fuzzy' low order bits, perhaps we should build in a more user-friendly default precision for the MATH context. Maybe have it controlled via a new WebDNA pref? Any thoughts? -----Original Message----- From: John Peacock [mailto:jpeacock@rowman.com] Sent: Thursday, September 11, 2003 12:23 PM To: WebDNA-Talk@talk.smithmicro.com Subject: Re: Odd [math] behaviour Paul Willis wrote: > I fully agree, I don't understand why any calculations or formatting are > required. This is simple subtraction. 6000.4-5300.3 is 700.1 a small > child could do it. > Unfortunately, computers are far stupider than even the smallest child. The advantage of using a computer over a child is that the computer actually does what you tell it to do and does it quickly (no "In a minute Daddy!"). A quick Google yielded a few useful pages: http://www.python.org/doc/current/tut/node14.html http://mindprod.com/jgloss/floatingpoint.html http://www.rwc.uc.edu/koehler/comath/14.html HTH John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Odd [math] behavior ( Brian Fries 2003)
  2. Re: Odd [math] behavior ( Glenn Busbin 2003)
  3. Re: Odd [math] behavior ( "Scott Anderson" 2003)
  4. Re: Odd [math] behavior ( John Peacock 2003)
  5. Re: Odd [math] behavior ( Brian Fries 2003)
  6. Re: Odd [math] behavior ( Chris List Recipient 2003)
  7. Re: Odd [math] behavior ( "Scott Anderson" 2003)
I cringed when I saw this thread, knowing that it would lead to a discussion of the inaccuracies of binary representation of decimal numbers. I got a kick out of the following quote (taken from one of the links John provided - Thanks, John!). "Floating point is by its nature inexact. It is probably best if you imagined that after every floating point operation, a little demon came in and added or subtracted a tiny number to fuzz the low order bits of your result..." I am sure that even the most experienced programmer has gotten 'bit' by this. So, I think the lesson here is to ALWAYS keep in mind the desired 'precision' when performing floating point arithmetic and use the [format x.xf] to ensure that you get what you expect. FEEDBACK REQUEST: Given that most WebDNA programmers would not expect to have to deal with those 'fuzzy' low order bits, perhaps we should build in a more user-friendly default precision for the MATH context. Maybe have it controlled via a new WebDNA pref? Any thoughts? -----Original Message----- From: John Peacock [mailto:jpeacock@rowman.com] Sent: Thursday, September 11, 2003 12:23 PM To: WebDNA-Talk@talk.smithmicro.com Subject: Re: Odd [math] behaviour Paul Willis wrote: > I fully agree, I don't understand why any calculations or formatting are > required. This is simple subtraction. 6000.4-5300.3 is 700.1 a small > child could do it. > Unfortunately, computers are far stupider than even the smallest child. The advantage of using a computer over a child is that the computer actually does what you tell it to do and does it quickly (no "In a minute Daddy!"). A quick Google yielded a few useful pages: http://www.python.org/doc/current/tut/node14.html http://mindprod.com/jgloss/floatingpoint.html http://www.rwc.uc.edu/koehler/comath/14.html HTH John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ "Scott Anderson"

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Sort Order on a page search (1997) WebCat2b13MacPlugin - [math][date][/math] problem (1997) Dummy Credit Card Number for debug? (1997) creating files dynamically (2002) Hiding Email Addresses (2003) before after on (1998) Auto entering Friday's date in a field (2002) Multiple catalog databases and showcart (1997) Problems with ^ could be solved with [REPLACE CHARACTERS] (1997) Price Not Appearing (2000) Searching a database... (2003) Shipping charges depending on tax rate? (1997) Problems getting parameters passed into email. (1997) disappearing SKU (etc.) fields (1998) is there a global includes directory? (1998) IE Cache Problems... (1999) duplicate cart numbers (2002) WebCatalog Upgrade Pricing? (1997) Problem displaying search result (1997) PCS Frames (1997)