accurate filesize of file
How would i return the filesize of a file to show the filesize in a not-so-big-# fashion.
Example: 1024bk into 1mb...
or so on...
I've never had to deal with filesize so idk what to do.
cuz i mean 1015742 bytes doesnt look that nice. When its 991 kilobytes
Which would look better? 991 kb or 1015742 b
Re: accurate filesize of file
1015742b! Get with the times man!
No really, just divide the size by 1024:
1024b = 1kb
1024kb = 1mb
1024mb = 1gig ect..
and if there is a remander just round up.
Re: accurate filesize of file
heh... simple as that eh...
how i round up?...
cuz 991.935546875 lol.
Re: accurate filesize of file
Re: accurate filesize of file
heh... floor() worked better.
round() when UP.. where as floor went down.
round() = 992
floor() = 991(Correct size)
Re: accurate filesize of file
Neither is "correct". round() rounds to nearest, half-up. floor() always rounds down. The file is 66 bytes short of 992k - wouldn't you agree that 992 is "more correct" than 991, which is 958 bytes off?
Re: accurate filesize of file
Acually your right... and i knew that.
But id rather have the base number without the remainder.
cuz if the numbers lets say 88.6394348 or w/e would you rather have it 89 or stay at 88?
Re: accurate filesize of file
Actually I don't particularly care. 500 bytes aren't going to kill me.
Re: accurate filesize of file
I would rather have it round up, so I know the max apx amount of space I would need.
Re: accurate filesize of file
Yeah... i thought that too... but ...
As the files in question arent on my server. i dont really have to worry.