Mikkel
(Fresh Scripter)
2014-11-14 08:32 AM
Numbers (noob)

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


Glenn BarnasAdministrator
(KiX Supporter)
2014-11-14 12:54 PM
Re: Numbers (noob)

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


Mikkel
(Fresh Scripter)
2014-11-15 01:31 PM
Re: Numbers (noob)

Thanks Glenn. This helped a lot. Thanks!