asak
December 21, 2011, 12:53am
1
Hi,
i want to convert number 5860533159 to hexadecimal. i need to use perl.
i used
$foo = 5860533159;
$hexval3 = sprintf("%#x", $foo);
i am getting value as 0xffffffff.
i need to get value as 0x15D50A3A7. when i converted using google calculator, i got the correct value, expected value must be 0x15D50A3A7.
Expected output:
10000 = 0x2710
5860533159 = 0x15D50A3A7
Need to do this in perl script.
Thanks,
Asak
$ perl test1.pl
0x15d50a3a7
$ cat test1.pl
#!/usr/bin/perl
$val=5860533159;
printf("%#x\n",$val);
---------- Post updated at 11:32 AM ---------- Previous update was at 11:29 AM ----------
if you want the output in upper case, then use "uc"
Works for me.
$ perl -e '$x=5860533159; printf "%#X\n", $x'
0X15D50A3A7
$ perl -e '$x=10000; printf "%#X\n", $x'
0X2710
asak
December 21, 2011, 1:05am
4
itkamaraj:
$ perl test1.pl
0x15d50a3a7
$ cat test1.pl
#!/usr/bin/perl
$val=5860533159;
printf("%#x\n",$val);
---------- Post updated at 11:32 AM ---------- Previous update was at 11:29 AM ----------
if you want the output in upper case, then use "uc"
Hi,
I am using the same script, but my output is 0xffffffff ..
Thanks,
asak
please answer for the below questions
1) OS - 32 bit or 64 bit ?
2) Perl version - 32 bit or 64 bit ?
asak
December 21, 2011, 1:09am
6
Hi,,
I am getting output as
~]$ perl -e '$x=5860533159; printf "%#X\n", $x'
0XFFFFFFFF
---------- Post updated at 01:09 AM ---------- Previous update was at 01:07 AM ----------
hi raj,
how to check this..
Regards,
asak
Post the output of following commands. It might help to figure the problem..
uname -a
echo $SHELL
perl -v
execute the below
$perl -we '$x=5860533159; printf "%#X\n", $x'
asak
December 21, 2011, 1:14am
9
hi,
$ uname -a
Linux lb.app.com 2.6.23.1-42.fc8 #1 SMP Tue Oct 30 13:55:12 EDT 2007 i686 i686 i386 GNU/Linux
$ echo $SHELL
/bin/csh
$ perl -v
This is perl, v5.6.1 built for i686-linux
Copyright 1987-2001, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
i suspect, you are using 32 bit complied perl version.
---------- Post updated at 11:46 AM ---------- Previous update was at 11:44 AM ----------
you have 32 bit perl and it will support the value upto 4294967295
---------- Post updated at 11:55 AM ---------- Previous update was at 11:46 AM ----------
use bitnum and BigInt
bignum - perldoc.perl.org
Math::BigInt - perldoc.perl.org ()