in reply to Hex Question(s)
Prepend '0x' to the string and it will maintain its numeric value.
Update: Added no warnings for the -w happy...#!/usr/bin/perl use strict; no warnings 'numeric'; my $this = sprintf("0x%x", 40); my $that = sprintf("0x%x", 2); my $other = $this + $that; printf "$other %x\n", $other; __END__ 42 2a
Update: This is perl, v5.6.0 built for i386-linux
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Hex Question(s)
by Corion (Patriarch) on Mar 27, 2008 at 16:36 UTC | |
Re^2: Hex Question(s)
by TGI (Parson) on Mar 27, 2008 at 16:51 UTC | |
Re^2: Hex Question(s)
by deadlock (Initiate) on Mar 27, 2008 at 16:38 UTC |
In Section
Seekers of Perl Wisdom