Re: Round to the nearest half!
This WebDNA talk-list message is from 2008
It keeps the original formatting.
numero = 69785
interpreted = N
texte = How many steps do you have?y = floor(x/.5)z = (y)(.5)r = x - zif r > .24 then y = y + 1multiply y*.5 again for the final answer[math]x=1.6543[/math][math]y=floor([x]/.5)[/math][math]z=[y]*.5[/math][math]r=[x]-[z][/math][showif [r]>.24] [math]y=[y]+1[/math][/showif][math]z=[y]*.5[/math]z is then your answer.Matthew A PerosiPsi Prime, Inc.http://www.psiprime.com323 Union Blvd.Totowa, NJ 07512P: 973.413.8210F: 973.413.8217Donovan Brooke wrote:> Hello,>> I am trying to round to the nearest .5 increment and> my code so far is too long winded. Here is your mission> should you choose to accept it:>> Round to the nearest half.. so:>> 1.6543>> Should return as 1.5>> If the number is absolutely between a half increment.. such> as in: 1.75, it should round up (becoming 2 in this case).>> Thanks,> Donovan>>-------------------------------------------------------------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:
How many steps do you have?y = floor(x/.5)z = (y)(.5)r = x - zif r > .24 then y = y + 1multiply y*.5 again for the final answer[math]x=1.6543[/math][math]y=floor([x]/.5)[/math][math]z=[y]*.5[/math][math]r=[x]-[z][/math][showif [r]>.24] [math]y=[y]+1[/math][/showif][math]z=[y]*.5[/math]z is then your answer.Matthew A PerosiPsi Prime, Inc.http://www.psiprime.com323 Union Blvd.Totowa, NJ 07512P: 973.413.8210F: 973.413.8217Donovan Brooke wrote:> Hello,>> I am trying to round to the nearest .5 increment and> my code so far is too long winded. Here is your mission> should you choose to accept it:>> Round to the nearest half.. so:>> 1.6543>> Should return as 1.5>> If the number is absolutely between a half increment.. such> as in: 1.75, it should round up (becoming 2 in this case).>> Thanks,> Donovan>>-------------------------------------------------------------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/
Matthew A Perosi
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:
MacActivity and PCS (1997)
Converting Esiting Html Table Forms to WebCat (1997)
[WebDNA] [OT] Google redirect or not (2014)
Change to 5.0 per website licensing (2003)
Searching multiple fields from one form field (1997)
Stats (2004)
Bad suffix error (1997)
Summing fields (1997)
Odd [math] behaviour (2003)
Error Log.db --however (1997)
Middle Context (2002)
[WebDNA] Searching for multiple bits of data in one field or use (2016)
WC1.6 to WC2 date formatting (1997)
Include a big block of text (1997)
Setting Cart value (2000)
[WebDNA] Snow Leopard and v7 (2011)
nesting limits? (1998)
[WebDNA] listcookies v Windows 7 (2011)
Error Lob.db records error message not name (1997)
Virus Alert: FBI Finds 911 Virus Wiping Out Hard Drives Today (2000)