Skip Menu |

This queue is for tickets about the Math-Geometry-Planar CPAN distribution.

Report information
The Basics
Id: 96784
Status: open
Priority: 0/
Queue: Math-Geometry-Planar

People
Owner: Nobody in particular
Requestors: user42_kevin [...] yahoo.com.au
Cc:
AdminCc:

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



Subject: centroid() warnings on BigFloat or BigRat coordinates
Date: Sat, 28 Jun 2014 10:52:30 +1000
To: bug-Math-Geometry-Planar [...] rt.cpan.org
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
If centroid() is called on points which have Math::BigFloat or Math::BigRat coordinates then various warnings are printed. For example foo.pl below Use of uninitialized value in pattern match (m//) at /usr/share/perl5/Math/BigFloat.pm line 710. ... In centroid() it seems the coordinate sums and total areas are started from undefs, my @c; my $total_area; It would help BigFloat and BigRat if they started as zeros my @c = (0, 0); my $total_area = 0; I believe it's a known shortcoming of BigFloat and friends that they don't "auto-vivify" like ordinary perl arithmetic. But I think it's usually cleaner for generic mathematical calculations not to mix undefs and numbers, but use 0 where 0 is meant. I struck this when trying BigRat to get exact answers. I'm not sure how well BigRat works with the $C_EPS bit of the triangulate(), but that would be another matter :).

Message body is not shown because sender requested not to inline it.

-- These prestigious wrought-iron security gates are bullet-proof, bomb-proof, and battering-ram resistant.
The reason for this behaviour is that Math::BigFloat is a math module, and in mathematics it does not make sense to add a number to an empty string or undefined value. If you want Perl semantics, add "use bignum;" at the top of your code. Then you should get support for arbitrarily large numbers with the semantics of Perl. Hope this help.
The reason for this behaviour is that Math::BigFloat is a math module, and in mathematics it does not make sense to add a number to an empty string or undefined value. If you want Perl semantics, add "use bignum;" at the top of your code. Then you should get support for arbitrarily large numbers with the semantics of Perl. Hope this help.