Skip Menu |

This queue is for tickets about the Convert-IBM390 CPAN distribution.

Report information
The Basics
Id: 49494
Status: resolved
Priority: 0/
Queue: Convert-IBM390

People
Owner: grommel [...] cpan.org
Requestors: joncombe [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.27
Fixed in: (no value)



Subject: Maximum limit?
The following code is giving results I think is wrong. #!/usr/bin/perl -w use strict; use Convert::IBM390 qw(:all); print packeb ( "p15.2" , "999999999999999.00" ); I am getting the 2 digits after the decimal point becoming 04 instead of the expected 00. Is this a limitation or a bug?
This is a limitation, not of Perl or the module, but of IEEE floating- point processors. IEEE 64-bit floating point uses 52 bits for the mantissa, so the maximum integer value that can be represented is 2^52 - 1 = 4503599627370495. Your input value is 17 digits, not 15, so it is beyond the precision of the processor. The following 15-digit value gives the expected results: packeb("p8.2", "9999999999999.00") By the way, the packeb template gives the number of bytes, not the number of digits, so "p9.2" is adequate for a 17-digit value. Unfortunately, the module does not support 128-bit floats ("quads"). Maybe someday. The limitations of floating-point numbers are well-known, but I probably should revise the POD to remind people of them. On Mon Sep 07 12:20:48 2009, joncombe wrote: Show quoted text
> The following code is giving results I think is wrong. > > #!/usr/bin/perl -w > > use strict; > use Convert::IBM390 qw(:all); > > print packeb ( "p15.2" , "999999999999999.00" ); > > > I am getting the 2 digits after the decimal point becoming 04 instead > of the expected 00. Is this a limitation or a bug?
Show quoted text
> By the way, the packeb template gives the number of bytes, not the > number of digits, so "p9.2" is adequate for a 17-digit value. > > Unfortunately, the module does not support 128-bit floats ("quads"). > Maybe someday. > > The limitations of floating-point numbers are well-known, but I > probably should revise the POD to remind people of them. >
You are correct about my usage, sorry about that. Thanks for taking the time to respond. Jon.
Closed. On Tue Sep 08 07:11:22 2009, joncombe wrote: Show quoted text
> > By the way, the packeb template gives the number of bytes, not the > > number of digits, so "p9.2" is adequate for a 17-digit value. > > > > Unfortunately, the module does not support 128-bit floats
("quads"). Show quoted text
> > Maybe someday. > > > > The limitations of floating-point numbers are well-known, but I > > probably should revise the POD to remind people of them. > >
> > You are correct about my usage, sorry about that. Thanks for taking
the Show quoted text
> time to respond. > Jon.