in reply to Unexpected behavior of a method in BigFloat

Math::BigFloat doesn't appear to have an as_int() method, and it doesn't look like its AUTOLOAD() will provide a non-trivial one.

There is an as_number() method which does what as_int() is documented to do. Changing the call to that in your code gives:

$ perl as_int.pl $float is a: Math::BigFloat $int is a: Math::BigInt $float 1.41421356237309504880168872420969807857 $int: 1 $
Documentation bug.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Unexpected behavior of a method in BigFloat
by spiritway (Vicar) on Nov 03, 2005 at 00:44 UTC

    Now you've got me curious... The POD for Math::BigFloat talks of this method. In fact, I even went to the author's Website for more information. He states that he added as_int() for v1.68 of this module.

    So my questions are, first, is this something that might be considered a "bug", since the documentation appears to conflict with the actual behavior of the method? IOW, should I perhaps report this to the author?

    Also important for my sanity, though, is how could I have avoided knocking my head against a wall? Such as, how did you know about as_number()? If I had known where to look, I could have saved myself hours of going crazy over this...

      Ah, that explains it, my version is 1.50.

      I found the problem in that version by running perldoc -m Math::BigFloat, giving the source listing. My pager is less so I'm able to search text by typing "/as_int". That found only the instance in pod. Finding where the as_* methods are by the same method, I noticed as_number and saw from its definition that it was what we wanted.

      Since it's been remedied in recent versions, I don't think it's worth bothering the author with it.

      After Compline,
      Zaxo