supersonic Posted July 21, 2016 Share Posted July 21, 2016 (edited) Hi - If running this code snippet Abs() "converts" Int32 into Double: Local $iSC_Countdown = -100 MsgBox(0, $iSC_Countdown, VarGetType($iSC_Countdown)) $iSC_Countdown = Abs($iSC_Countdown) MsgBox(0, $iSC_Countdown, VarGetType($iSC_Countdown)) Why? Is it a bug? Greets, -supersonic. EDIT: Testet with 3.3.12 and 3.3.15. EDIT (#2): Abs() doesn't preserve the variable type if input is integer. If it is behaviour by design maybe it is worth to be mentioned in help file? Edited July 21, 2016 by supersonic Link to comment Share on other sites More sharing options...
mikell Posted July 21, 2016 Share Posted July 21, 2016 Local $iSC_Countdown = -100 $iSC_Countdown = Abs($iSC_Countdown) MsgBox(0, $iSC_Countdown, IsInt($iSC_Countdown)) Link to comment Share on other sites More sharing options...
spudw2k Posted July 21, 2016 Share Posted July 21, 2016 (edited) Interesting observation and behavior. I'm curious what (if any) scenarios you have run into that this would cause issues (me thinks lower-level RAM allocation perhaps)? edit: Same behavior observed when using Abs on a positive Int Local $iSC_Countdown = 100 MsgBox(0, $iSC_Countdown, VarGetType($iSC_Countdown)) $iSC_Countdown = Abs($iSC_Countdown) MsgBox(0, $iSC_Countdown, VarGetType($iSC_Countdown)) ;simple workaround Func _Abs($iValue) If $iValue < 0 Then $iValue *= -1 Return $iValue EndFunc $iSC_Countdown = -200 MsgBox(0, $iSC_Countdown, VarGetType($iSC_Countdown)) $iSC_Countdown = _Abs($iSC_Countdown) MsgBox(0, $iSC_Countdown, VarGetType($iSC_Countdown)) Edited July 21, 2016 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
supersonic Posted July 22, 2016 Author Share Posted July 22, 2016 I observed this behaviour incidently. It would be very helpful to know if this is an unmeant inconsistency. I could live with it but then it should be documented in help file. Perhaps a dev could enlight us? A workaround can be helpful - but only in special cases. Variable types should be preserved (where logical). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now