Re: Odd [math] behaviour
This WebDNA talk-list message is from 2003
It keeps the original formatting.
numero = 52772
interpreted = N
texte = WebDna @ wrote:> 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.> I'm sorry, you're right. The docs say [format] will round to the number of decimal places requested (when used with the 'f'). For some reason, I thought it would truncate. The C library sprintf("%.2f",var) is supposed to round, though some libraries don't do it correctly.I always try to do my currency math using integer number of pennies and display a decimal place during output. I even wrote a Perl module which does this, because this is the only 100% accurate way to perform math with currency values.John-- John PeacockDirector of Information Research and TechnologyRowman & Littlefield Publishing Group4501 Forbes BoulevardSuite HLanham, MD 20706301-459-3366 x.5010fax 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/
Associated Messages, from the most recent to the oldest:
WebDna @ wrote:> 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.> I'm sorry, you're right. The docs say [format] will round to the number of decimal places requested (when used with the 'f'). For some reason, I thought it would truncate. The C library sprintf("%.2f",var) is supposed to round, though some libraries don't do it correctly.I always try to do my currency math using integer number of pennies and display a decimal place during output. I even wrote a Perl module which does this, because this is the only 100% accurate way to perform math with currency values.John-- John PeacockDirector of Information Research and TechnologyRowman & Littlefield Publishing Group4501 Forbes BoulevardSuite HLanham, MD 20706301-459-3366 x.5010fax 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/
John Peacock
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:
Date Search (2004)
[shownext max (1997)
Nested tags count question (1997)
[replace] has protection feature like [delete]? (2000)
ShowNext for method=POST (1997)
MOOOOOO (2000)
problem (how to mark orders as 'opened') (1998)
OT - SE robot question (2003)
I'm new be kind (1997)
tcpconnect return (2003)
checksum for credit cards? (1997)
Possible Bug in 2.0b15.acgi (1997)
Colocator Upgrading OS (2004)
Comments in db? (1997)
More news on 5.0 (2003)
Document Contains No Data! (1997)
Newspaper Portal (2005)
RE: Credit card processing - UK (1997)
WebCatalog Use Question (1997)
incrementing a counter remotely? (1999)