Re: Odd [math] behaviour

This WebDNA talk-list message is from

2003


It keeps the original formatting.
numero = 52771
interpreted = N
texte = John, Can I ask what exactly is wrong with using the [format]? It returned the answer he wanted. it has always returned the correct answer dealing with math in the cart adding cost. RonnyMc ----- Original Message ----- From: "John Peacock" To: "WebDNA Talk" Sent: Thursday, September 11, 2003 11:14 AM Subject: Re: Odd [math] behaviour > Pat Holliday wrote: > > > But that's not the answer - the answer is 700.1.. > > > > Why doesn't WebDNA do straightforward calculations by default? > > > > It's your computer, not WebDNA. Floating point math is not exact; it is > approximate. Certain combinations will not ever work in the way you are used to > "on paper" so you just have to deal with it. > > I see that round() is not a valid function within the [math] (which is dumb), so > you'll have to brew your own: > > [math]floor((6000.4-5300.3+0.005)*100)/100[/math] > > will display what you would expect. > > NOTE: because you are using floating point, even the above may not work all of > the time, because some decimal representations are not possible to accurately > store using floating point numbers (which are stored internally as a power of 2 > not 10). > > 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] behaviour ( Tim Robinson 2003)
  2. Re: Odd [math] behaviour ( John Peacock 2003)
  3. Re: Odd [math] behaviour ( Paul Willis 2003)
  4. Re: Odd [math] behaviour ( Donovan 2003)
  5. Re: Odd [math] behaviour ( John Peacock 2003)
  6. Re: Odd [math] behaviour ( "WebDna @" 2003)
  7. Re: Odd [math] behaviour ( John Peacock 2003)
  8. Re: Odd [math] behaviour ( Donovan 2003)
  9. Re: Odd [math] behaviour ( "WebDna @" 2003)
  10. Re: Odd [math] behaviour ( Pat Holliday 2003)
  11. Re: Odd [math] behaviour ( "WebDna @" 2003)
  12. Re: Odd [math] behaviour ( John Peacock 2003)
  13. Odd [math] behaviour ( Pat Holliday 2003)
John, Can I ask what exactly is wrong with using the [format]? It returned the answer he wanted. it has always returned the correct answer dealing with math in the cart adding cost. RonnyMc ----- Original Message ----- From: "John Peacock" To: "WebDNA Talk" Sent: Thursday, September 11, 2003 11:14 AM Subject: Re: Odd [math] behaviour > Pat Holliday wrote: > > > But that's not the answer - the answer is 700.1.. > > > > Why doesn't WebDNA do straightforward calculations by default? > > > > It's your computer, not WebDNA. Floating point math is not exact; it is > approximate. Certain combinations will not ever work in the way you are used to > "on paper" so you just have to deal with it. > > I see that round() is not a valid function within the [math] (which is dumb), so > you'll have to brew your own: > > [math]floor((6000.4-5300.3+0.005)*100)/100[/math] > > will display what you would expect. > > NOTE: because you are using floating point, even the above may not work all of > the time, because some decimal representations are not possible to accurately > store using floating point numbers (which are stored internally as a power of 2 > not 10). > > 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/ "WebDna @"

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:

WebCat2 Append problem (B14Macacgi) (1997) Replace context problem ... (1997) ISAPI WC6a and Windows 2003 Web Edition (2006) Can WC remember people? (1998) RE: Template not found error messages (1997) First postarg not taking in $Commands (1997) Sort Order on a page search (1997) PCS Emailer's role ? (1997) DON'T use old cart file! (1997) Email SMTP Error 411 (2006) convertWords... NEW (2001) A Global Variable (1997) WebCat2 beta 11 - new prefs ... (1997) FORMS: Returning a specific page (1997) Shopping Cart Limits? (1998) RE: Emailer prefs in two places ... (1997) Satistics (1999) Number searching/formats (1998) weird happenings (1997) PCS Emailer's role ? (1997)