in reply to [OT] Function to do x**y for |y|<1 w/o ** operator.
Does he have log and exp available?
print exp( log( 100 ) *.5 );; 10 print exp( log( 1000 ) *.3333333333333333333333 );; 10
Ie.
sub pow{ exp( log( $_[0] ) * $_[1] ) };; printf "%2d : %20.17f\n", $_, pow( 10**$_, 1/$_ ) for 1 .. 20;; 1 : 10.00000000000000200 2 : 10.00000000000000200 3 : 9.99999999999999820 4 : 10.00000000000000200 5 : 10.00000000000000200 6 : 9.99999999999999820 7 : 9.99999999999999820 8 : 10.00000000000000200 9 : 9.99999999999999820 10 : 10.00000000000000200 11 : 10.00000000000000200 12 : 9.99999999999999820 13 : 10.00000000000000200 14 : 9.99999999999999820 15 : 9.99999999999999820 16 : 10.00000000000000200 17 : 10.00000000000000200 18 : 9.99999999999999820 19 : 10.00000000000000200 20 : 10.00000000000000200 printf "%2d : %20.17f\n", $_, pow( 12345**$_, 1/$_ ) for 1 .. 20;; 1 : 12345.00000000000500000 2 : 12345.00000000000500000 3 : 12345.00000000000500000 4 : 12345.00000000000500000 5 : 12345.00000000000500000 6 : 12345.00000000000500000 7 : 12345.00000000000500000 8 : 12345.00000000000500000 9 : 12345.00000000000500000 10 : 12345.00000000000500000 11 : 12345.00000000000500000 12 : 12345.00000000000500000 13 : 12345.00000000000500000 14 : 12345.00000000000500000 15 : 12344.99999999998400000 16 : 12345.00000000000500000 17 : 12344.99999999998400000 18 : 12345.00000000000500000 19 : 12344.99999999998400000 20 : 12345.00000000000500000
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|
---|
In Section
Seekers of Perl Wisdom