I'm not sure I understand that, but my guess is that you don't.
You code does spit out the appropriate decimal values...
- 33
- 45
- 57
- 69
- ...
and, as line 100, 1221
...so, as I understand your inital question and followup, your issue is presentation or formatting; not the arithmetic, nor any error in the syntax you've shown us (note, however, that your loop is not particularly perlish).
updateFollowing up on (well, preceding up on ???) toolic's suggestion with an example using pack/unpack:
for (my $i = 1; $i <= 20; $i++) {
$a+=0x0C;
$out = pack "c", $a;
$hex = unpack "H2", $out;
print "\t$i Now, \$a (as decimal) is:\t$a \tand as hex: 0x$hex\n";
}
And if this is indeed homework, the implicit suggestion of Fletch's comment may be "FGS, at least label it as such."
| [reply] [d/l] |
Thank you,
your last comment did help very well.
| [reply] |