Jump to content

How do I convert Bytes to Megabytes?


PalmTree

Recommended Posts

Posted

Is there any mathematical formula to convert Bytes to Megabytes?

For example I have a car mod that's 7.30 MB. I use fileGetSize, but it returns bytes. And I'd like to know how many Megabytes it are instead of Bytes.

Thanks

Posted (edited)

I'm not 100% sure but,

NumberOfBytes/1048576

or

  
function convertBtoMB(b) 
     if b then 
          return b/1048576 
     end 
     return false 
end 
  

Edited by Guest
Posted

1024 bytes = 1 kb

1024 kb = 1 mb

Example:

131584 bytes / 1024 = 128.5 kb / 1024 = 0.125 mb

Posted
1024 bytes = 1 kb

1024 kb = 1 mb

Example:

131584 bytes / 1024 = 128.5 kb / 1024 = 0.125 mb

Thanks for the help, I managed to make it working.

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
  • Recently Browsing   0 members

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