Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: int() function

by holli (Abbot)
on Oct 24, 2020 at 13:47 UTC ( [id://11123120]=note: print w/replies, xml ) Need Help??


in reply to int() function

C:\>rakudo -e "say (1.15*170)+0.5" 196
#MathThatWorks #Rakulang


holli

You can lead your users to water, but alas, you cannot drown them.

Replies are listed 'Best First'.
Re^2: int() function
by syphilis (Archbishop) on Oct 24, 2020 at 14:00 UTC
    C:\>rakudo -e "say (1.15*170)+0.5" 196


    That's interesting - I thought that raku was above producing that sort of braindead bullshit.
    Is it rounding to the nearest integer ?
    Or maybe it's doing decimal math ?

    UPDATE: aaah ... I think I get it ... 1.15 is being evaluated as the rational value 115/100 ... right ?

    Cheers,
    Rob
      Yes, Raku has a Rat type which stores (and normalizes) numerator and denominator. Legend has it they only did that so they can have a .nude method (which returns a Pair).


      holli

      You can lead your users to water, but alas, you cannot drown them.
        I find it confusing that a bareword of 1.15 can be assigned exactly as the rational 115/100 rather than as the approximated double.
        But I guess that one would adapt quickly enough to the change of mindset, if one had to.

        Cheers,
        Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2025-06-22 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.