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:
Questions To Answer (1997)
Secure server question (1997)
[WebDNA] grep again (2010)
webmerch and serials - almost there (1997)
Can you do this??? and other stuff (1997)
Never ending problem.... (2000)
Cannot calculate prices (1997)
Some Questions (1997)
Linebreaks and [writefile] (2003)
Using Plug-In while running 1.6.1 (1997)
Search (1997)
[WebDNA] [regex] (2015)
email preferences on NT (1997)
Summ=T Problem (1997)
One other big addition... (1997)
[convertChars] and HTML Tags (1997)
with Link i need to (1997)
PIXO (1997)
RE: formula.db, adding option prices (1997)
Help! WebCat2 bug (1997)