Results 1 to 10 of 10

Thread: accurate filesize of file

  1. #1

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    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.

  2. #2
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    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.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  3. #3

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    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.

  4. #4
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: accurate filesize of file

    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  5. #5

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    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.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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.

  7. #7

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    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.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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.

  9. #9
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: accurate filesize of file

    I would rather have it round up, so I know the max apx amount of space I would need.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  10. #10

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    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
  •  



Click Here to Expand Forum to Full Width