|
-
Jan 9th, 2006, 09:58 PM
#1
Thread Starter
Hyperactive Member
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
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
-
Jan 9th, 2006, 10:30 PM
#2
Fanatic Member
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.
-
Jan 9th, 2006, 10:44 PM
#3
Thread Starter
Hyperactive Member
Re: accurate filesize of file
heh... simple as that eh...
how i round up?...
cuz 991.935546875 lol.
Last edited by PlaGuE; Jan 9th, 2006 at 10:49 PM.
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
-
Jan 9th, 2006, 10:59 PM
#4
Fanatic Member
Re: accurate filesize of file
-
Jan 10th, 2006, 04:45 AM
#5
Thread Starter
Hyperactive Member
Re: accurate filesize of file
heh... floor() worked better.
round() when UP.. where as floor went down.
round() = 992
floor() = 991(Correct size)
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
-
Jan 10th, 2006, 07:13 AM
#6
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?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 10th, 2006, 07:33 PM
#7
Thread Starter
Hyperactive Member
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?
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
-
Jan 10th, 2006, 07:38 PM
#8
Re: accurate filesize of file
Actually I don't particularly care. 500 bytes aren't going to kill me.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 10th, 2006, 09:40 PM
#9
Fanatic Member
Re: accurate filesize of file
I would rather have it round up, so I know the max apx amount of space I would need.
-
Jan 11th, 2006, 04:19 AM
#10
Thread Starter
Hyperactive Member
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.
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|