View unanswered posts | View active topics It is currently Tue Apr 16, 2024 1:28 pm



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: 1396
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.
-= 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
Profile ICQ YIM
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1131
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 7 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 STSoftware.