|
|
|||||||
ok, what am I doing wrong? I need to calculate (divide) 2 numbers and then multiply by 100 to get the average. Kix can add, subtract and multiple but can't divide? $foo = 5 $bar = 10 $foo + $bar - returns 15 $foo - $bar - returns -5 $foo * $bar - returns 50 ... but ... $foo / $bar - returns ... zero? |
||||||||
|
|
|||||||
It's partly the way you defined your numbers and it's the way Kix generally handles numbers. It can be worked around though. FTR, if you had tried $bar / $foo it would have worked. You can define a number as Double to avoid the problem. So instead of 5 you can define as 5.0. Or you can use the function CDBL to do it, ie CDBL($foo). |
||||||||
|
|
|||||||
I understand what you are saying. My data is being retrieved via a WMI query and the calculation is actually part of a script to determine the percentage of free disk space. Casting the value as Double (CDBl) was probably the only function I didn't try. ... one moment, please ... |
||||||||
|
|
|||||||
Casting the value(s) as CDBL worked! ... I think that is the only options I didn't try before! I knew it had to be something stupid simple. As always, thank you @allen |
||||||||
|
|
|||||||
$data = WmiQuery(get disk things...) $FreePct = 1.0 * $data.free / $data.size Multiplying by 1.0 FIRST tells Kix that the entire operation should use double-precision math without calling a function or changing the values. Adding 0.0 to an add/subtract has the same net effect. Glenn |
||||||||
|
|
|||||||
BTW - What platform are you using for monitoring, or is this just for information gathering and reporting? |