Sign in to follow this  
Followers 0
Grimster

Autoit devs need to take a math class.......

29 posts in this topic

#1 ·  Posted (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 by Grimster

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by KaFu

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Mikeman27294

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

I corrected my original post and the original code is now correct, please reread it now.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by KaFu

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I'm not joking at all. Edit: Well, at least not at the moment :)...

299961.93792 MB * 1024 = 307.161.024 (.43008 ???) Bytes

It 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 by Grimster

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Does't work.

Yes we know the drivespacetotal command does not work right, thats the whole point of this thread.

Share this post


Link to post
Share on other sites

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

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#18 ·  Posted (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 by KaFu

Share this post


Link to post
Share on other sites

What's this?

Melba23 what's the result of the OP's code and what is it that properties display on your system?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  
Followers 0