luciffer 0 Posted October 1, 2012 First i don't know if this is something that you already know. But eater i have some error in coding or AutoIT wasn't designed to do this way. Its a simple function that calculates four digits in decimal number, eg. 1.256 returns 1256, at least what it suppose to do. But when i run the code below instead of numbers 1003 i get 1002. It turned out that when 1.003 gets multiplied with 1000 it becomes 1002.99999999989 instead of 1003. So is this normal because of float number representation in PC or something else I'm not aware of? Func Temperature($T) Local $C0, $C1, $C2, $C3 $T = $T *1000 $C0 = Int($T / 1000) $C1 = Int(($T - ($C0 * 1000)) / 100) $C2 = Int(($T - ($C0 * 1000) - ($C1 *100))/10) $C3 = Int($T - ($C0 * 1000) - ($C1 *100) - ($C2 *10)) ToolTip($C0 & $C1 & $C2 & $C3,500,0) Sleep(3000) EndFunc Temperature(1.003) Share this post Link to post Share on other sites
water 2,359 Posted October 1, 2012 (edited) That's a problem with the internal representation of decimal numbers as binary. There has been a lengthy discussion about this lately. I will post the link as soon as I find it.Edit: Here is the Edited October 1, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
bogQ 91 Posted October 1, 2012 (edited) from help fileExampleLocal $var = Int(10.793) ;$var is the integer 10so why are you using Int? shudnt you use$C3 = Round($somedata, 0) ?! Edited October 1, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Share this post Link to post Share on other sites