maniootek Posted January 16, 2016 Share Posted January 16, 2016 Guys I have no idea what's wrong so I think it's a bug in autoit or I am lack of some knowledge. Please take a look: expandcollapse popup#include <Array.au3> local $array[0] _ArrayAdd($array, "54.83") _ArrayAdd($array, "48.99") _ArrayAdd($array, "25.58") _ArrayAdd($array, "26.99") _ArrayAdd($array, "43.99") _ArrayAdd($array, "40") _ArrayAdd($array, "29.94") _ArrayAdd($array, "183.68") _ArrayAdd($array, "20.99") _ArrayAdd($array, "35.98") _ArrayAdd($array, "26.99") _ArrayAdd($array, "80.99") _ArrayAdd($array, "35.89") _ArrayAdd($array, "87") _ArrayAdd($array, "60.99") _ArrayAdd($array, "60.99") _ArrayAdd($array, "29.39") _ArrayAdd($array, "382") _ArrayAdd($array, "47.98") _ArrayAdd($array, "42.99") _ArrayAdd($array, "40.99") _ArrayAdd($array, "44.98") _ArrayAdd($array, "86.99") _ArrayAdd($array, "31.49") _ArrayAdd($array, "169.99") _ArrayAdd($array, "40.98") _ArrayAdd($array, "37.88") _ArrayAdd($array, "47.99") _ArrayAdd($array, "35.89") _ArrayAdd($array, "257.21") _ArrayAdd($array, "29.39") _ArrayAdd($array, "37.99") _ArrayAdd($array, "83.99") _ArrayAdd($array, "26.99") _ArrayAdd($array, "40.99") _ArrayAdd($array, "23.98") _ArrayAdd($array, "117.4") _ArrayAdd($array, "37.99") _ArrayAdd($array, "525.4") _ArrayAdd($array, "40.99") _ArrayAdd($array, "26.99") _ArrayAdd($array, "35.88") _ArrayAdd($array, "29.99") _ArrayAdd($array, "50.98") _ArrayAdd($array, "53.66") _ArrayAdd($array, "43.99") _ArrayAdd($array, "54") _ArrayAdd($array, "40.99") _ArrayAdd($array, "26.99") _ArrayAdd($array, "24.49") _ArrayAdd($array, "49.49") _ArrayAdd($array, "42.99") _ArrayAdd($array, "46.99") _ArrayAdd($array, "97") _ArrayAdd($array, "21.48") _ArrayAdd($array, "80") _ArrayAdd($array, "69") _ArrayAdd($array, "167.7") _ArrayAdd($array, "103.93") _ArrayAdd($array, "319.2") _ArrayAdd($array, "112.96") _ArrayAdd($array, "55.99") _ArrayAdd($array, "32.89") _ArrayAdd($array, "43.99") _ArrayAdd($array, "83.99") _ArrayAdd($array, "86.99") _ArrayAdd($array, "32.89") _ArrayAdd($array, "34.98") _ArrayAdd($array, "40.99") _ArrayAdd($array, "33") _ArrayAdd($array, "35.49") _ArrayAdd($array, "26.78") _ArrayAdd($array, "150.7") _ArrayAdd($array, "87") ;when you sum up this all number it should gives result 5370.6 but it gives 5370.05999999999 _ArrayDisplay($array) $Result = "0.0" for $i=0 to Ubound($array) - 1 $Result += $array[$i] Next msgbox(0,0,$Result) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 16, 2016 Moderators Share Posted January 16, 2016 maniootek, No bug. Look up "floating point arithmetic" and you will see it is a result of how computers store doubles. The solution? Convert to integers and then reconvert the result: $Result = 0 For $i = 0 To UBound($array) - 1 $Result += 100 * $array[$i] Next MsgBox(0, 0, $Result / 100) M23 Skysnake 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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