Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^5: Can I access and use UV types from perl? (updated)

by haukex (Archbishop)
on Nov 17, 2019 at 20:36 UTC ( [id://11108829]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Can I access and use UV types from perl?
in thread Can I access and use UV types from perl?

bignum still appears to store the value as an IV though.

No, they're objects*. See the output of perl -Mbignum -MDevel::Peek -e 'my $x=1; Dump($x)' or perl -Mbignum -MData::Dump -e 'my $x=1; dd($x)'.

It would seem that some kind of overloading solution may be the way to go, let Perl handle the storage, but overload the operations with XSUBS that do type checking/coercion. Or even straight up Inlining C.

Well, again, if you don't tell us what for, we can't really comment.

* Update: I guess you maybe mean internally? The point is, how they're stored internally is abstracted and encapsulated in an object, and you shouldn't worry about it. bignum will allow you to work with numbers of any size and any precision without any loss due to the usual floating-point imprecisions, overflows, etc.

Replies are listed 'Best First'.
Re^6: Can I access and use UV types from perl? (updated)
by Don Coyote (Hermit) on Nov 17, 2019 at 21:33 UTC

    for the greater understanding and enoblement of homus erectus.

    That and, well one reason may be to help with the documentation on the Rat() function in Perl 6. By understanding what Perl is doing with numbers at the level of the Naturals we can possibly figure out how to convert the Rationals into Reals and update the Docs accordingly.

    Well that and just sanity in general.

      That and, well one reason may be to help with the documentation on the Rat() function in Perl 6.

      My understanding from a quick look at the Raku (formerly known as Perl 6) documentation is:

      • int is a native integer, so like Perl's IV
      • Int is like Perl's Math::BigInt (bignum; note that enables Math::BigFloats too)
      • Num is a native float, so like Perl's NV
      • Rat is basically like two integers for numerator and denominator, overflowing causes it to be cast to Num (which seems like a downgrade to me)
      • FatRat is like Perl's Math::BigRat (bigrat)

      I don't see an equivalent of Math::BigFloat in Raku at the moment.

      By understanding what Perl is doing with numbers at the level of the Naturals

      I think Perl's data types are much more closely aligned with the underlying native types than with mathematical concepts like natrual numbers, whole numbers, etc.

      we can possibly figure out how to convert the Rationals into Reals

      According to the docs, role Rational[::NuT, ::DeT] does Real { ... } already...?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108829]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-26 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found