Grimster Posted December 18, 2011 Share Posted December 18, 2011 (edited) DriveSpaceTotal command reports the incorrect drive size. Whoever the person was who created this command has his/her math all wrong. They are clearly confused with the Binary bytes to Decimal bytes conversion. Currently all the command does is take a decimal representation of the current BINARY bytes and multiplies it only once by 1024 then simply moves the decimal place over to show MBs. That is an incorrect way to convert and produces a completely wrong answer. Here is the code/math to correct the incorrect math built into the DriveSpaceTotal command $HDspace = DriveSpaceTotal("c:") MsgBox(0,"incorrect hard drive space in Mbs",$hdspace);----before correction $hdspace = $hdspace * 1000000 $hdspace = $hdspace/1024 $hdspace = $hdspace/1000000 $hdspace = $hdspace*1024*1024*1024 $hdspace = $hdspace/1000000 msgbox(0,"Correct hard drive space in Mbs",$hdspace);-----after correction This correction will now give you the EXACT size of a partition. Note if you have only one user created partition like c: , even with the corrected math you will not get a perfect 120,000mb, or 500,000mb, or 1,000,000mb simply because Windows XP and Windows 7 reserve a small hidden partition of 8mb or 100mb which throws off the exact size of the ENTIRE drive. You can always use the Round command to round off the the nearest decimal point in MB or GB Edited December 18, 2011 by Grimster Link to comment Share on other sites More sharing options...
KaFu Posted December 18, 2011 Share Posted December 18, 2011 (edited) Have you ever paid attention to what Windows Explorer reports?$HDspace = DriveSpaceTotal("c:") MsgBox(0,"",$hdspace / 1024)Edit: , Wikipedia calls this "Consumer Confusion". How about next time asking a nice question instead of starting with an insult. Maybe you need to attend some social classes... Edited December 18, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Mikeman27294 Posted December 18, 2011 Share Posted December 18, 2011 (edited) I have just tested this and it is correct.I checked it against the property dialoge for the C drive, and under the graphical representation of the free / taken space, it shows bytes available and the script given did show it correctly.I think that maybe you should submit this to bug reports rather than try and make a fool of the developers, because that is the number 1 way to have the moderators come down on you like a tonne of bricks.And KaFu, that didn't work properly, either Wait, no it isnt, it shows GB correctly. My bad. Edited December 18, 2011 by Mikeman27294 Link to comment Share on other sites More sharing options...
KaFu Posted December 18, 2011 Share Posted December 18, 2011 1 GB <> 1024 * 1024 * 1024 Bytes = 1.073.741.824 Bytes = 1 Gibibyte 1 Gigabyte = 1.000.000.000 Bytes OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Grimster Posted December 18, 2011 Author Share Posted December 18, 2011 I corrected my original post and the original code is now correct, please reread it now. Link to comment Share on other sites More sharing options...
KaFu Posted December 18, 2011 Share Posted December 18, 2011 Still not correct, your "correction" reports 299961.93792 MB for my C drive, Windows Explorer reports 299.961.937.920 Bytes. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Grimster Posted December 18, 2011 Author Share Posted December 18, 2011 Still not correct, your "correction" reports 299961.93792 MB for my C drive, Windows Explorer reports 299.961.937.920 Bytes.Now you're just making fun of me.....thats the EXACT same number. Link to comment Share on other sites More sharing options...
KaFu Posted December 18, 2011 Share Posted December 18, 2011 (edited) I'm not joking at all. Edit: Well, at least not at the moment ... 299961.93792 MB * 1024 = 307.161.024 (.43008 ???) Bytes Edit: Please re-read the Wikipedia article. The problem is that you don't have a 300GB C drive but a 279GB one. What you have installed is an 300 Gibibyte Harddrive. Edit: Arrgh, it's so confusing that I've mixed up the terms , you've installed a 300 Gigabyte HDD, but Windows reports 279 Gibibyte, which is relevant number you need for all file related calculations. Edited December 18, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Grimster Posted December 18, 2011 Author Share Posted December 18, 2011 (edited) I'm not joking at all. Edit: Well, at least not at the moment ...299961.93792 MB * 1024 = 307.161.024 (.43008 ???) BytesIt does not work like that. First you have to tell us what size drive you have and if you have more than one user created partition. If you got 299,961.93792 AFTER my correction then you have a 300gb hard drive (assuming you have not created any other partitions than c:) My correction does not show 300,000mb exactly because as stated Windows reserves a small hidden partion of 8mb for XP and 100mb for Win7 and Vista.What my correction does show is the EXACT and CORRECT decimal number of bytes on your c: partition or any other partition you please to seek the size of.If you desire to obtain the ENTIRE size of the drive (again assuming only one user partiton of c:) simply use the Round command to the nearest mb or gb decimal place AFTER my mathematical correction to the DriveSpaceTotal command Edited December 18, 2011 by Grimster Link to comment Share on other sites More sharing options...
KaFu Posted December 18, 2011 Share Posted December 18, 2011 Your correction shows: 299961.93792 MB * 1024 = 307.161.024 (.43008 ???) Bytes My drive info says: 299.961.937.920 Bytes Which is exactly DriveSpaceTotal("c:") * 1024 * 1024 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Mikeman27294 Posted December 18, 2011 Share Posted December 18, 2011 If you desire to obtain the ENTIRE size of the drive (again assuming only one user partiton of c:) simply use the Round command to the nearest mb or gb decimal place AFTER my mathematical correction to the DriveSpaceTotal commandNot correct - A 500Gb drive may be 499Gb or it may be 501Gb. The manufacturers just sell it off as a 500Gb HDD for the sake of keeping round numbers.And KaFu's script does work perfectly fine, showing the drive size in GB. Take a look at it with a drive properties window open and you will see it is correct. Link to comment Share on other sites More sharing options...
Grimster Posted December 18, 2011 Author Share Posted December 18, 2011 I dont know what you are talking about, my correction is 100% perfect. I just tested it on another computer 40gb hard drive with only one user partition of c: Windows correctly report 37.2xxxxxxx BINARY gbs drivespacetotal incorrectly reports : 38146.49609375 mb. Incorrect in both binary and decimal My correction correctly report 39999.500288 in decimal Again, my correction does not show a perfect 40,000 mb because as stated Windows reserves a small hidden partiton of 8mb or 100mb. Link to comment Share on other sites More sharing options...
JohnOne Posted December 18, 2011 Share Posted December 18, 2011 Does't work. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Grimster Posted December 18, 2011 Author Share Posted December 18, 2011 Not correct - A 500Gb drive may be 499Gb or it may be 501Gb. The manufacturers just sell it off as a 500Gb HDD for the sake of keeping round numbers.And KaFu's script does work perfectly fine, showing the drive size in GB. Take a look at it with a drive properties window open and you will see it is correct.This is 100% wrong, Hard drive manufactures do not "round off" the storage space on the drives they sell. If they advertise 500gb the drives they sell have EXACTLY 500,000,000,000 locations to store a byte. Link to comment Share on other sites More sharing options...
Grimster Posted December 18, 2011 Author Share Posted December 18, 2011 Does't work.Yes we know the drivespacetotal command does not work right, thats the whole point of this thread. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2011 Moderators Share Posted December 18, 2011 Grimster,Your code in the OP does indeed match what Windows properties tells me about the size of my drives and I suggest you open a Trac ticket to report your findings and see what the Devs have to say about it. However, if you want a sympathetic hearing, I would strongly suggest that you take a rather less accusatory tone when you write the ticket. And it would not hurt your cause if you renamed this thread either - perhaps to "Possible error in DriveSpaceTotal". Just edit the first post and use the "Full Editor" option - you can then access the title. M23 Mikeman27294 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...
Mat Posted December 18, 2011 Share Posted December 18, 2011 This is 100% wrong, Hard drive manufactures do not "round off" the storage space on the drives they sell. If they advertise 500gb the drives they sell have EXACTLY 500,000,000,000 locations to store a byte.Yes, but a lot of those locations are reserved for uses other than files. AutoIt Project Listing Link to comment Share on other sites More sharing options...
KaFu Posted December 18, 2011 Share Posted December 18, 2011 (edited) The HDD manufactures sell you their drives with the mathematical correct 300 GB, where a Gigabyte = 1.000.000.000 Byte. Windows shows you the Gibibyte values, where a Gibibyte is 1.073.741.824 Bytes. And for all file related operations this is the only value that is of any use... Edited December 18, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
trancexx Posted December 18, 2011 Share Posted December 18, 2011 What's this? Melba23 what's the result of the OP's code and what is it that properties display on your system? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2011 Moderators Share Posted December 18, 2011 trancexx, I get these values - Vista x32 if that makes any difference: Drive C: M: DriveSpaceTotal = 253 549 992 187 99 999 996 093 His correction = 265 866 436 608 104 857 555 404 Windows = 265 866 436 608 104 857 595 404 The first 2 values come from the OP's code, the Windows values are those given by selecting the drive in Explorer and looking at the Properties dialog. M23 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