Joined: Mon Jun 16, 2003 2:00 am Posts: 639 Location: USA
the use of Decimals in scripting
does twx use decimals yet?
for example... if I get and answer of .7
twx see this as 0
Wed Jan 23, 2013 4:40 pm
LoneStar
Commander
Joined: Fri Jun 09, 2006 2:00 am Posts: 1400 Location: Canada
Re: the use of Decimals in scripting
been a while since i've worked with dcimals. you can use the SetPrecision script command:
Code:
setvar $X 10 setvar $Y 100
setPrecision 2
Divide $Y $X
Echo "**" & $Y & "**"
setPrecision 0
_________________ ---------------------------- -= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time. -=There are 10 types of people in the world: Those that understand Binary and those who do not -=If Oil is made from Dinosaurs, and Plastic is made from Oil... are plastic Dinosaurs made from real Dinosaurs? -=I like to keep my friends and my enemies rich, and wait to see which is which - Tony Stark (R.I.P.)
Wed Jan 23, 2013 5:04 pm
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1133 Location: Augusta, GA
Re: the use of Decimals in scripting
By default, TWX treats numbers as integers. It will apply decimal precision if you first specify the desired precision. Use the command setPrecision to specify the number of decimal places, up to 18, that you want returned. This remains in effect until you specify a different precision. You can also round (using the round command) to a specific number of decimals after you've first used the setPrecision command. I've introduce truncate as well, but I'm not sure if it's in the build of TWX you're using... but feel free to test it.
Users browsing this forum: No registered users and 96 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum