View unanswered posts | View active topics It is currently Fri Apr 17, 2026 4:17 am



Reply to topic  [ 3 posts ] 
 the use of Decimals in scripting 
Author Message
Veteran Op
User avatar

Joined: Mon Jun 16, 2003 2:00 am
Posts: 639
Location: USA
Unread post 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
Profile ICQ
Commander
User avatar

Joined: Fri Jun 09, 2006 2:00 am
Posts: 1401
Location: Canada
Unread post 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.


Wed Jan 23, 2013 5:04 pm
Profile ICQ YIM
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post 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.

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Mon Jan 28, 2013 6:47 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 11 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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.