Jump to content
Sign in to follow this  
DarkMadMax

Large negative number problem .Also select case question

Recommended Posts

DarkMadMax

So I have a number, excel calculates it to 2.6317E-16 -nothing too big, but it shows as 0 in autoit. Anyway to make it work ? -I really need to see differences

Here is how I get it in autoit:

$probability=($PhoM/$count)*($IntM/$count)*($WilM/$count)*($strM/$count)*($EndM/$count)*($DexM/$count)*($AgiM/$count)* _

($SpeM/$count)*($EyeM/$count)*($HeaM/$count)*($SmeM/$count)*($TouM/$count)

Another thing Is I tried to uses select case for testing multiple conditions, but it was just not working - it was firing every time regardless of comparison result. I just coded it with ifs which worked fine, but looks like broken select to me. Here is example :

CODE

select

case PixelGetColor ($xInt,$yInt,$sHWnd) == $skillcolor

$IntM+=1

continuecase

select PixelGetColor($xWill,$yWill,$sHWnd) = $skillcolor

$WilM+=1

continuecase

case PixelGetColor($xStr,$yStr,$sHWnd) = $skillcolor

$StrM+=1

endselect

Share this post


Link to post
Share on other sites
PsaltyDS

So I have a number, excel calculates it to 2.6317E-16 -nothing too big, but it shows as 0 in autoit. Anyway to make it work ? -I really need to see differences

Here is how I get it in autoit:

$probability=($PhoM/$count)*($IntM/$count)*($WilM/$count)*($strM/$count)*($EndM/$count)*($DexM/$count)*($AgiM/$count)* _

($SpeM/$count)*($EyeM/$count)*($HeaM/$count)*($SmeM/$count)*($TouM/$count)

You don't provide any values for the variables. I don't see any problems working with that value:
; 2.6317E-16
$iNum = 2.6317 * 10^-16
ConsoleWrite("$iNum = " & $iNum & @LF)
$iNum *= 10^16
ConsoleWrite("$iNum = " & $iNum & @LF)
$iNum = 2.6317
ConsoleWrite("$iNum = " & $iNum & @LF)
For $n = 1 To 16
    $iNum /= 10
    ConsoleWrite("$iNum = " & $iNum & @LF)
Next

You probably got it from Excel as a string "2.6317E-16" rather than a number, but AutoIt's automatic variant types seem to handle that just fine:

; 2.6317E-16
$sNum = "2.6317E-16"
ConsoleWrite("$sNum = " & $sNum & "  Type = " & VarGetType($sNum) & @LF)
$iNum = $sNum * 10^16
ConsoleWrite("$iNum = " & $iNum & "  Type = " & VarGetType($iNum) & @LF)

You need to post some code that actually shows and example of something not working...

:P

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Spiff59

select 

case PixelGetColor ($xInt,$yInt,$sHWnd) == $skillcolor 
$IntM+=1 
continuecase
select PixelGetColor($xWill,$yWill,$sHWnd) = $skillcolor 
$WilM+=1 
continuecase
case PixelGetColor($xStr,$yStr,$sHWnd) = $skillcolor 
$StrM+=1
endselect

Regarding your Select statement (I assume that's a typo and meant to be another "case" in the middle rather than a second nested select statement).

I believe both the Select and Switch statements execute through the first true condition, and then exit. The continuecase option forces it to jump to and execute the code beneath the next case statement, but it does not perform the test for that case. So, if your first case is true, continuecase will make it jump straight to your "$WilM+=1" regardless of whether or not the comparison in the second case is true. If you need to perform each of those tests independantly, then sequential "If" statements would be the way to go.

$probability=($PhoM/$count)*($IntM/$count)*($WilM/$count)*($strM/$count)*($EndM/$count)*($DexM/$count)*($AgiM/$count)* _
($SpeM/$count)*($EyeM/$count)*($HeaM/$count)*($SmeM/$count)*($TouM/$count)

Wouldn't this get you the same result?

$probability=($PhoM*$IntM*$WilM*$strM*$EndM*$DexM*$AgiM*$SpeM*$EyeM*$HeaM*$SmeM*$TouM) / ($count^12)
Edited by Spiff59

Share this post


Link to post
Share on other sites
DarkMadMax

You don't provide any values for the variables. I don't see any problems working with that value

values are calculated on the fly. just I was getting a zero and wrote them into log file, then I did multiply them in excel and got e-16, so I figured autoit was rounding it to 0 for some reason :/

So what I ended up doing is reading that log file in excel and calculating them there.

Regarding your Select statement (I assume that's a typo and meant to be another "case" in the middle rather than a second nested select statement).

I believe both the Select and Switch statements execute through the first true condition, and then exit. The continuecase option forces it to jump to and execute the code beneath the next case statement, but it does not perform the test for that case. So, if your first case is true, continuecase will make it jump straight to your "$WilM+=1" regardless of whether or not the comparison in the second case is true. If you need to perform each of those tests independantly, then sequential "If" statements would be the way to go.

Seems like continuecase pointless then :/ Isn't testing subsequent statements on continue is how it works in most other languages?

Wouldn't this get you the same result?

$probability=($PhoM*$IntM*$WilM*$strM*$EndM*$DexM*$AgiM*$SpeM*$EyeM*$HeaM*$SmeM*$TouM) / ($count^12)
Yes it would , but I was adding values so i thought just cutting pasting without altering the exponent. I thought also that exponent would be a bit faster but methinks compiler optimizations actually should take care of those

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.