Is it possible to round a number like this in the example?
for example
Round(12.25) = 12
Round(12.50) = 12
Round(12.75) = 12
Round a number
Moderators: Dorian (MJT support), JRL
- Grovkillen
- Automation Wizard
- Posts: 1128
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Round a number
i found it
Let>a=301.6
Let>a={Trunc(%a%)}
msg a
Let>a=301.6
Let>a={Trunc(%a%)}
msg a
Re: Round a number
Is it possible to truncate a number like this?
Round(12) = 10
Round(15) = 10
Round(19) = 10
Re: Round a number
Divide by 10, trunc and x10 again.
Re: Round a number
found it again
Code: Select all
label>start
random>9999,a
if>a>1000
let>rounding=1000
goto>found
endif
if>a>100
let>rounding=100
goto>found
endif
if>a>10
let>rounding=10
goto>found
endif
label>found
let>b=a
Let>b={Trunc(%b%/%rounding%)*%rounding%}
msg %a% %b%
wait>1
goto>start