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 the nearest hundred when you have large numnbers, you'll need to adjust the default case below to check if temp = 10 in which case you'll need to adjust accordingly (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 next higer [math]temp=ceil([getChars start=1&end=1][num][/getChars].[getChars start=2&end=2][num][/getChars])[/math] [return][temp]00[/return] [/case] [default] - for all cases of 4+ digits [math]temp=ceil([getChars start=3&end=3&from=end][num][/getChars].[getChars start=2&end=2&from=end][num][/getChars])[/math] [return][getChars start=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 number 15557984 = [round100 num=15557984]
-----Original Message----- From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf Of Stuart Tremain Sent: Friday, December 07, 2007 5:13 PM To: WebDNA Talk Subject: Round UP to nearest 100 How can I round up to nearest 100? Regards Stuart Tremain IDFK Web Developments AUSTRALIA webdna@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 to Web 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:

    
  1. Re: Round UP to nearest 100 ( "Olin Lagon" 2007)
  2. Re: Round UP to nearest 100 ( "Olin Lagon" 2007)
  3. Re: Round UP to nearest 100 ( Stuart Tremain 2007)
  4. Round UP to nearest 100 ( Stuart Tremain 2007)
Heh Stuart, here is some code that works. If you need rounding up the the nearest hundred when you have large numnbers, you'll need to adjust the default case below to check if temp = 10 in which case you'll need to adjust accordingly (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 next higer [math]temp=ceil([getChars start=1&end=1][num][/getChars].[getChars start=2&end=2][num][/getChars])[/math] [return][temp]00[/return] [/case] [default] - for all cases of 4+ digits [math]temp=ceil([getChars start=3&end=3&from=end][num][/getChars].[getChars start=2&end=2&from=end][num][/getChars])[/math] [return][getChars start=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 number 15557984 = [round100 num=15557984]
-----Original Message----- From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf Of Stuart Tremain Sent: Friday, December 07, 2007 5:13 PM To: WebDNA Talk Subject: Round UP to nearest 100 How can I round up to nearest 100? Regards Stuart Tremain IDFK Web Developments AUSTRALIA webdna@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 to Web 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:

Emailer setup (1997) Emailer (WebCat2) (1997) formatting dates from a field ... (1997) SSL and WebCatalog (1997) Search inside Include (1998) WCS Newbie question (1997) Help with Shipping Costs (1997) Shopping Cart variation... (1997) [writefile] (1997) Emailer setup (1997) How to Display text in empty fields (1997) Configuring E-mail (1997) Modulo function? (2000) File Upload, Browser Timeout (2003) Special search (1998) Date Formats (1997) WCS Newbie question (1997) Multiple Users.db Possible? (1997) changing creator codes (2000) Frames (1997)