Skip Menu |

This queue is for tickets about the Number-Format CPAN distribution.

Report information
The Basics
Id: 51248
Status: rejected
Priority: 0/
Queue: Number-Format

People
Owner: Nobody in particular
Requestors: mneeff [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.60
  • 1.72
Fixed in: (no value)



Subject: Floating point precision does not seem to work correctly
Floating point precision up to 3 or more decimal places does not seem to work in Number-Format versions 1.60 or higher. Please run the following sample script in 1.60 or 1.72: !/usr/bin/perl use Number::Format; my $usd2 = new Number::Format(-thousands_sep => ',', -decimal_point => '.', -decimal_digits => 2, -decimal_fill => 1, -int_curr_symbol => '$'); my $usd3 = new Number::Format(-thousands_sep => ',', -decimal_point => '.', -decimal_digits => 3, -decimal_fill => 1, -int_curr_symbol => '$'); my $usd4 = new Number::Format(-thousands_sep => ',', -decimal_point => '.', -decimal_digits => 4, -decimal_fill => 1, -int_curr_symbol => '$'); my $price = 145.12345; my $show_price = $usd2->format_price($price); print "$show_price \n"; my $show_price = $usd3->format_price($price); print "$show_price \n"; my $show_price = $usd4->format_price($price); print "$show_price \n"; -The above script works in 1.52. This was required in one of our business applications.
There was a bug in older versions of Number::Format where it would use decimal_digits. But it should use int_frac_digits and was changed to do so a while back. Alternately you can pass the precision as an argument to format_price() as an additional argument.