in reply to Re^5: Split any number into string of 8-bit hex values (=1 byte)
in thread Split any number into string of 8-bit hex values (=1 byte)
Well.... I'm not sure how your regex works BUT it works great for unsigned numbers :-)
unsigned signed numbers
It doesn't completely solve my problem as it does not work with#!/usr/bin/perl use strict; use warnings; sub number2hexString { return my $output .= join ' ', map { join ' ', sprintf('%016X' +, $_) =~ s/^0{8}(0{4}(00)?)?//r =~ /../g } @_; } print number2hexString(2,20,200,2000,20000,200000)."\n";
UPDATE: sorry, I was confused, obviously the last sentence should read ... does not work with signed numbers
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: Split any number into string of 8-bit hex values (=1 byte) (updated)
by AnomalousMonk (Bishop) on Aug 30, 2021 at 22:00 UTC | |
Re^7: Split any number into string of 8-bit hex values (=1 byte)
by AnomalousMonk (Bishop) on Aug 30, 2021 at 22:53 UTC | |
by tybalt89 (Prior) on Aug 30, 2021 at 22:59 UTC | |
by AnomalousMonk (Bishop) on Aug 30, 2021 at 23:03 UTC | |
Re^7: Split any number into string of 8-bit hex values (=1 byte)
by tybalt89 (Prior) on Aug 30, 2021 at 22:41 UTC | |
by soonix (Canon) on Aug 31, 2021 at 07:04 UTC | |
by AnomalousMonk (Bishop) on Aug 31, 2021 at 07:49 UTC | |
Re^7: Split any number into string of 8-bit hex values (=1 byte)
by tybalt89 (Prior) on Aug 30, 2021 at 21:02 UTC |
In Section
Seekers of Perl Wisdom