Re: [Mojolicious] Mojo::JSON and Math::Big...

2014-06-30 Thread Gabriel Vieira
Sorry.. I just saw Math::BigFloat source code it also contains a numify method (that implements +0 in the return). So.. correct code should be: --8-- use Mojo::JSON 'j'; use Math::BigFloat; use Math::BigInt; my $float = Math::BigFloat-new(12.34)-numify; my $int =

Re: [Mojolicious] Mojo::JSON and Math::Big...

2014-06-30 Thread sri
use Math::BigFloat; use Math::BigInt; Send patches for those modules and add TO_JSON methods. ;) -- sebastian -- You received this message because you are subscribed to the Google Groups Mojolicious group. To unsubscribe from this group and stop receiving emails from it, send an email

Re: [Mojolicious] Mojo::JSON and Math::Big...

2014-06-30 Thread David Oswald
It seems to me that adding a TO_JSON method that calls -bstr() will get you the existing behavior; that is, the modules already overload stringification such that JSON encoding will trigger stringification. In short, sub TO_JSON { shift()-bstr() } should just get you existing behavior. I think

Re: [Mojolicious] Mojo::JSON and Math::Big...

2014-06-30 Thread Tekki
Am Montag, 30. Juni 2014 22:37:57 UTC+2 schrieb David Oswald: What kind of number would you return them as? Let's consider Math::BigInt: I realize that it is not as simple as I thought at the beginning. My problem was just that libraries like AngularJS aren't very happy when they have to

Re: [Mojolicious] Mojo::JSON and Math::Big...

2014-06-30 Thread David Oswald
This isn't a Mojo::JSON problem, nor a Math::BigInt or Math::BigFloat problem. And it won't be a JavaScript problem either. It is a problem of what happens when a floating point number is represented internally in binary format, regardless of the language. Any JSON library on any platform is