Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Number with More then 15 Digits.
_
Hi 

$a = 1234567890123456789; 
printf ("%0.0f\n", $a);

Out Put is 
1234567890123456800

which is wrong can any one let meknow how do we handle 
Digits More than 15 digits ..

Regards
Govardhan MV



Report this thread to moderator Post Follow-up to this message
Old Post
Govardhan M. V
04-26-05 08:57 PM


Re: Number with More then 15 Digits.
On 26 Apr 2005 11:35:59 -0000, Govardhan M. V wrote:
> =20
> Hi
>=20
> $a =3D 1234567890123456789;
> printf ("%0.0f\n", $a);
>=20
> Out Put is
> 1234567890123456800
>=20
> which is wrong can any one let me know how do we handle
> Digits More than 15 digits ..
>=20

There is no "wrong" here. When trying to store a number larger than
the largest integer possible on your platform, perl converts to float.
Any C app compiled with the same compiler would do the same.
For details of when and which conversions take place, read "perldoc
perlnumber". Anyway, you can use Math::BigInt to handle large
integers.

HTH,
--=20
Offer Kaye

Report this thread to moderator Post Follow-up to this message
Old Post
Offer Kaye
04-26-05 08:57 PM


Re: Re: Number with More then 15 Digits.
On 26 Apr 2005 13:35:27 -0000, Govardhan M. V wrote:
>=20
>    Hi,
>  Thanks for the help,
>  put i tried this=20
>  use Math::BigInt;
>  $a =3D Math::BigInt->new("12345678901234567890");
>  printf("%.0f\n",$a);
> =20
>  out put is=20
>  12345678901234567168
> =20
>  which is not right so please do let me know how do i go about it .
>  My problem is in printing. can you let me  know how do i over come this
> issue.
> =20

Hi,
Please don't top post. Please don't use HTML emails. Please reply to the li=
st.

With that out of the way, Depending on your needs, you can use "%s" as
the printf format string, or use simply print:
################ begin code
use strict;
use warnings;
use Math::BigInt;
my $num =3D Math::BigInt->new("12345678901234567890");
print "Orig string:   12345678901234567890\n";
printf "printf output: %s\n",$num;
print "print output:  $num\n";
################ end code

HTH,
--=20
Offer Kaye

Report this thread to moderator Post Follow-up to this message
Old Post
Offer Kaye
04-26-05 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:35 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.