in reply to Split any number into string of 8-bit hex values (=1 byte)
DB<20> print join " ", reverse split /(..)/ , sprintf "%06x\n", 2*10* +*$_ for 0..5 02 00 00 14 00 00 c8 00 00 d0 07 00 20 4e 00 40 0d 03 DB<21>
I'm not sure why you want low bytes first, but please note you had trailing 00s in your example too.
this will give you the number of necessary bytes
DB<29> say 1+int (log (2*10**$_)/log 256) for 0..5 1 1 1 2 2 3
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split any number into string of 8-bit hex values (=1 byte)
by LanX (Saint) on Aug 30, 2021 at 14:00 UTC | |
by LanX (Saint) on Aug 30, 2021 at 14:29 UTC |