Jump to content

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


Grimster
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Link to comment
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.

Link to comment
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.

Link to comment
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.
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...