Re: Round UP to nearest 100
This WebDNA talk-list message is from 2007
It keeps the original formatting.
numero = 69571
interpreted = N
texte = Heh Stuart, here is some code that works. If you need rounding up the thenearest hundred when you have large numnbers, you'll need to adjust thedefault case below to check if temp = 10 in which case you'll need to adjustaccordingly (maybe slap an if statement before the return).Laters, Olin===[function name=round100][math]chars=[countchars][num][/countchars][/math][switch value=[chars]][case value=1]- for single digit numbers, always return 100[return]100[/return][/case][case value=2]- for double digit numbers, always return 100[return]100[/return][/case][case value=3]- for triple digit numbers, figure out the nexthiger[math]temp=ceil([getCharsstart=1&end=1][num][/getChars].[getCharsstart=2&end=2][num][/getChars])[/math][return][temp]00[/return][/case][default]- for all cases of 4+ digits[math]temp=ceil([getCharsstart=3&end=3&from=end][num][/getChars].[getCharsstart=2&end=2&from=end][num][/getChars])[/math][return][getCharsstart=1&end=[math]chars-3[/math]][num][/getChars][temp]00[/return][/default][/switch][return][/return][/function]1 = [round100 num=1]
99 = [round100 num=99]
344 = [round100 num=344]
944 = [round100 num=944]
1344 = [round100 num=1344]
15557884 = [round100 num=15557884]
9xx will produce a wrong number15557984 = [round100 num=15557984]
-----Original Message-----From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf OfStuart TremainSent: Friday, December 07, 2007 5:13 PMTo: WebDNA TalkSubject: Round UP to nearest 100How can I round up to nearest 100?RegardsStuart TremainIDFK Web DevelopmentsAUSTRALIAwebdna@idfk.com.au-------------------------------------------------------------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 toWeb 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:
Heh Stuart, here is some code that works. If you need rounding up the thenearest hundred when you have large numnbers, you'll need to adjust thedefault case below to check if temp = 10 in which case you'll need to adjustaccordingly (maybe slap an if statement before the return).Laters, Olin===[function name=round100][math]chars=[countchars][num][/countchars][/math][switch value=[chars]][case value=1]- for single digit numbers, always return 100[return]100[/return][/case][case value=2]- for double digit numbers, always return 100[return]100[/return][/case][case value=3]- for triple digit numbers, figure out the nexthiger[math]temp=ceil([getCharsstart=1&end=1][num][/getChars].[getCharsstart=2&end=2][num][/getChars])[/math][return][temp]00[/return][/case][default]- for all cases of 4+ digits[math]temp=ceil([getCharsstart=3&end=3&from=end][num][/getChars].[getCharsstart=2&end=2&from=end][num][/getChars])[/math][return][getCharsstart=1&end=[math]chars-3[/math]][num][/getChars][temp]00[/return][/default][/switch][return][/return][/function]1 = [round100 num=1]
99 = [round100 num=99]
344 = [round100 num=344]
944 = [round100 num=944]
1344 = [round100 num=1344]
15557884 = [round100 num=15557884]
9xx will produce a wrong number15557984 = [round100 num=15557984]
-----Original Message-----From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf OfStuart TremainSent: Friday, December 07, 2007 5:13 PMTo: WebDNA TalkSubject: Round UP to nearest 100How can I round up to nearest 100?RegardsStuart TremainIDFK Web DevelopmentsAUSTRALIAwebdna@idfk.com.au-------------------------------------------------------------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 toWeb 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/
"Olin Lagon"
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:
Mozilla/4. and Browser Info.txt (1997)
What am I missing (1997)
Sitebuilder (2004)
Draft Manual, Tutorial, and more (1997)
[WebDNA] showif with empty variable (2015)
Problems passing [SKU] with $Replace in 2.0 (1997)
European Dates (1998)
WebCat2b13MacPlugIn - More limits on [include] (1997)
Multiple fields on 1 input (1997)
form data submission gets truncated (1997)
Big Databases (1997)
Math Context (2001)
Webcat engine freezes when [tcpconnect] can't connect (2003)
Thanks ! (1997)
[WebDNA] Mac Question (2018)
WebCat2b13MacPlugIn - [showif][search][/showif] (1997)
Resume Catalog ? (1997)
email preferences on NT (1997)
Calculating Shipping charges for multiple items and qtys > 1 (1997)
Multiple catalog databases and showcart (1997)