Page 1 of 1 1
Topic Options
#209646 - 2014-11-14 08:32 AM Numbers (noob)
Mikkel Offline
Fresh Scripter

Registered: 2006-03-15
Posts: 7
Hi there.

Im writing a script to extract free space on a disk drive, which is easy. However the number is in kilobytes. I want to multiply it with 1024 because i need to run the number in another command, however the calculation gives me a negative number. This is because of the limitation in kixtart - what do you other guys do?

$RESULT1 = GETDISKSPACE ( "C:\" )
? $RESULT1

$RESULT2 = $RESULT1*1024
? $RESULT2

Output:
7673544
-732225536

Top
#209647 - 2014-11-14 12:54 PM Re: Numbers (noob) [Re: Mikkel]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
You've reached the limit of Integer math - you need to convert to Real numbers..

 Code:
$Result = 1.0 * GetDiskSpace('C:')
$Result = $Result * 1024.0
will insure that you convert the GetDiskSpace result to a Real number, and keeping the ".0" is just a precaution added to the "1024".

As long as you start your formula with a Real value (decimal point), Kix will treat the entire expression as a Real value.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209652 - 2014-11-15 01:31 PM Re: Numbers (noob) [Re: Glenn Barnas]
Mikkel Offline
Fresh Scripter

Registered: 2006-03-15
Posts: 7
Thanks Glenn. This helped a lot. Thanks!
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.051 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org