Wrong amount returned by FileSize()

Just starting out? Need help? Post your questions and find answers here.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Wrong amount returned by FileSize()

Post by collectordave »

Seems to be same problem.


Maybe a little confused.

I have a file on my hard drive which in finder is shown with a size of 16,3MB.

When I use FileSize() on the file it returns 16295002 which I assume are bytes

Now I thought that there are 1048576 bytes in a mega byte so in 16,3MB should there not be 1709152,8 bytes approx?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
nsstudios
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

Re: Wrong amount returned by FileSize()

Post by nsstudios »

I'd still consider it a bug if the x86 and x64 compilations don't perform the same way, unless it's actually a certain limitation.
About 16295002 being 16.3 MB, I believe this is the case of good ol' base 10 vs base 2 shenanigans (MB vs MiB). If we divide 16295002 by 1000000, then we get 16.295002 MB, which they appear to round up, but why they don't use MiB instead is beyond me.
Looking it up, this link seems to confirm my theory: https://support.apple.com/en-us/HT201402
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Wrong amount returned by FileSize()

Post by collectordave »

Yes it does appear that Apple have decided that there are 1000 bytes in a kilobyte etc.

So 50 years of learning that there are 1024 bytes in a kilobyte all for nothing.

Apple cheating me out of 2.5% of storage space?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply