in reply to Re: Non-integer print output???
in thread Non-integer print output???

> (Maybe the question you should ask is "Why does the ** operator always return an NV ?". I don't know.)

The exponentiation operator a**b is IIRC optimized to generally handle float input for a and b and is approximating the result.

The result is hence usually a float.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Non-integer print output???
by syphilis (Archbishop) on Sep 10, 2021 at 14:33 UTC
    The exponentiation operator a**b is IIRC optimized to generally handle float input for a and b and is approximating the result.

    Does this arise because C's pow/powl/powq functions take floating point inputs and return floating point values ?
    I've always assumed so, without ever really knowing.

    I'm a little surprised that the C language doesn't provide a pow() function that takes and returns signed long int (or signed long long int) values - though I guess such a function would easily overflow for relatively low input values.

    Cheers,
    Rob
      As I said, it's AFAIR an approximation algorithm.

      I quickly found efficient integer algorithms too, can't tell why they are not included.

      I suppose it's provided by the CPU/ MMU?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery