If you want nice printed output rounded then the printf "%.0f" deal is a very tidy way to go.
If you are trying to figure allocation blocks, you need to always round up and use the allocation size of where you are going.
For example, I did a program to split up multiple files to put on floppies and so that looked something like.
my $size=-s _;
my $blocks=int($size/512)+1;
Floppy blocks were 512 bytes and there were 2880 of them on a disk less the formatting.
Also could add a check for a file exactly a multiple of 512 for which this code will reserve an extra block.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.