Re: Rounding problem
This WebDNA talk-list message is from 1998
It keeps the original formatting.
numero = 21979
interpreted = N
texte = When you use [format] to round the numbers, you are only rounding what isbeing displayed. The variables are being set inside the math context, andthen their values are being rounded for display. If you want to round thevariables themselves, you'd have to do the rounding within the [math]context:[math]x2=[format .2f][math]6.13*0.21[/math][/format][/math]-DaveAt 9:28 AM 12/20/98, abarguia wrote:>I can't find a solution in some rounding situations.>Here's a case that illustrates perfectly my problem:>>[math]change=40.807[/math]>[format .2f][math]x1=250/change[/math][/format] => 6.13>[format .2f][math]x2=6.13*0.21[/math][/format] => 1.29>[format .2f][math]x1+x2[/math][/format] => 7.41 instead of 7.42 (6.13+1.29)>>Is there a way to get 7.42? This simple question is a serious issue for me.>I have a lot of use of this structure with more complex calculations.>Is there a mean to tell to webcatalog to store, for example, exactly 6.13>into x1 (or another variable) and not the result with all the decimals.>That could ne a workaround, I think.>>heleneo--------------- Dave MacLeay --+o----------- Digital Frontier --+o--------------- 802.253.8612 --+o--- dave@digitalfrontier.com --+
Associated Messages, from the most recent to the oldest:
When you use
[format] to round the numbers, you are only rounding what isbeing displayed. The variables are being set inside the math context, andthen their values are being rounded for display. If you want to round thevariables themselves, you'd have to do the rounding within the
[math]context:
[math]x2=[format .2f]
[math]6.13*0.21[/math][/format][/math]-DaveAt 9:28 AM 12/20/98, abarguia wrote:>I can't find a solution in some rounding situations.>Here's a case that illustrates perfectly my problem:>>
[math]change=40.807[/math]>[format .2f]
[math]x1=250/change[/math][/format] => 6.13>[format .2f]
[math]x2=6.13*0.21[/math][/format] => 1.29>[format .2f]
[math]x1+x2[/math][/format] => 7.41 instead of 7.42 (6.13+1.29)>>Is there a way to get 7.42? This simple question is a serious issue for me.>I have a lot of use of this structure with more complex calculations.>Is there a mean to tell to webcatalog to store, for example, exactly 6.13>into x1 (or another variable) and not the result with all the decimals.>That could ne a workaround, I think.>>heleneo--------------- Dave MacLeay --+o----------- Digital Frontier --+o--------------- 802.253.8612 --+o--- dave@digitalfrontier.com --+
Dave MacLeay
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:
Search Form (2000)
[/application] error? (1997)
Date search - yes or no (1997)
WebCat2b13MacPlugIn - syntax to convert date (1997)
WebCat Code and WebStar Search? (2000)
ErrorMessages.db suggestion (1997)
Calendar (1997)
founditems / writefile (2005)
Automated FTP from Shell - Update (2004)
New Command prefs ... (1997)
Country & Ship-to address & other fields ? (1997)
listfiles, moving files (1998)
AutoCommit Preference? (1998)
(1997)
Exclamation point (1997)
killer-format in cart (1998)
Use of Back and Reload Buttons on ShoppingCart page? (1997)
[TaxableTotal] - not working with AOL and IE (1997)
WC2b15 File Corruption (1997)
Discounts: Buy One, Get One =?ISO-8859-1?Q?99=A2?= (2004)