Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:19:04+00:00 2026-06-03T13:19:04+00:00

I am using following code to get the available disk space of the startup

  • 0

I am using following code to get the available disk space of the startup disk.

NSFileManager *fm = [NSFileManager defaultManager];

double freeSpace = 0.0;
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfFileSystemForPath:@"/" error:nil];
if (!error) {
    freeSpace = [[attr objectForKey:NSFileSystemFreeSize] doubleValue];
}
//Convert from bytes to GB.
freeSpace = freeSpace/(1024*1024*1024);

But for MacOS 10.6 and above, it is giving the wrong size. After a while, I found out that for 10.5, we need to divide it by (1024*1024*1024) to get the correct available size. And for 10.6 and above, I have to divide it by (1000*1000*1000) to get correct size (which is displayed in Finder when we do right click on HardDisk -> Get Info).
Now, I don’t think dividing by 1000 instead of 1024 is the correct way for converting from KB to MB or whatever. So why is it like this in Mac 10.6 and above?

Is there any other function through which I can get available startup disk space correct upto 2 decimal points?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:19:05+00:00Added an answer on June 3, 2026 at 1:19 pm

    Disk drives, except some types of floppy drives, have always been described and sold in terms of powers of 1000. Memory has used powers of 1024, traditionally (ab)using the SI power-of-1000 prefixes. Programmers have tended to follow the memory convention, but it has never been universal and unambiguous.

    In 1999, the IEC recommended using SI prefixes (kilo, mega etc.) only for powers of 1000, and using a new set of prefixes for powers of 1024. Since 10.6, Mac OS X follows this recommendation for disks and files – thus more closely matching the advertised size of disks – but continues to use SI prefixes for powers of 1024 for RAM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to get current latitude and longitude. But none of
I'm using the following code to get an array with all sub directories from
I am using the following code to get make an IMAP connection. I am
I am using the following code to get an XML data from a website
We are using the following code to get the groups of an active directory
I'm using the following code to get response from a requested page using php
I'm currently using the following PHP code: // Get all subordinates $subords = array();
Using following code I try to get updated list of checkbuttons' corresponding text values,
With the following code I get all the pages I admin on Facebook using
I am using following PHP code for trigger creation but always get error, please

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.