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:
Templates on Unix & CGI on Mac? (1997)
format and math on the fly (1998)
Strange intermittent WebDNA problems (2008)
japanese characters (1997)
WebCatalog NT beta 18 now available (1997)
rename a file (1997)
[shownext max (1997)
[WebDNA] Adding Graphics to Directory (2009)
Shipping charge question (2003)
Word Bolding (1996)
Problem with broken images (2004)
Getting total number of items ordered (1997)
Resume Catalog ? (1997)
The beginning (1997)
[WebDNA] BUG REPORT [MATH show=t] WebDNA 8.6.1 & 8.6.3 server (2019)
Two submit buttons ? (1997)
Formatting a .txt file (1998)
Counting records (2000)
[addlineitems] as oppossed to url command=add (2000)
Problems setting MIME Headers (1998)