www.ClassicTW.com
http://classictw.com/

the use of Decimals in scripting
http://classictw.com/viewtopic.php?f=15&t=33700
Page 1 of 1

Author:  Muss [ Wed Jan 23, 2013 4:40 pm ]
Post subject:  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

Author:  LoneStar [ Wed Jan 23, 2013 5:04 pm ]
Post subject:  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


Author:  ElderProphet [ Mon Jan 28, 2013 6:47 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/