Do not use on any
shared computer
August 30, 2008 04:37am pdt
 
[x]
Attachment Details

Convert bytes to kb/mb

I have an integer that holds an amount of bytes. How would I make a function that returns an NSString with a value of kb or mb depending on what is appropriate.

So if the value of bytes is over 1024 show in KB and if its over 1024 KB show it in MB. Also I need it to round to one decimal place.

Examples:
55803 returns @"54.5 KB"
3671316 returns @"3.5 MB"
362 returns @"362 B" <- No decimals if in bytes :p

Thanks,
Max
Start your free trial to view this solution
Question Stats
Zone: Apple
Question Asked By: TheMaximumWeasel
Question Asked On: 02.21.2008
Participating Experts: 1
Points: 500
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by enrique_salazar
Expert Comment by enrique_salazar:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by TheMaximumWeasel
Author Comment by TheMaximumWeasel:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by enrique_salazar
Expert Comment by enrique_salazar:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by TheMaximumWeasel
Author Comment by TheMaximumWeasel:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by enrique_salazar
Expert Comment by enrique_salazar:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by TheMaximumWeasel
Author Comment by TheMaximumWeasel:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by enrique_salazar
Expert Comment by enrique_salazar:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by TheMaximumWeasel
Author Comment by TheMaximumWeasel:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by enrique_salazar
Expert Comment by enrique_salazar:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Administrative Comment by Vee_Mod
Administrative Comment by Vee_Mod:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628