Lumio Posted June 15, 2007 Share Posted June 15, 2007 Hi! I try to calculate a high number: 2^100 so I make it like that: pow(2, 100); My result is 1.26765060023E+30 How can I calculate with that value. Or do I have to replace that by my own. Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 15, 2007 Share Posted June 15, 2007 BCMath functions? Quote Link to comment Share on other sites More sharing options...
Lumio Posted June 15, 2007 Author Share Posted June 15, 2007 Hey thanks! I'll try that... later But thanks! Quote Link to comment Share on other sites More sharing options...
Lumio Posted June 15, 2007 Author Share Posted June 15, 2007 Okay... That's great... but I can't calc roots. For example: bcpow(4, 0.5) -> should get 2 ... but I get 1 Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 16, 2007 Share Posted June 16, 2007 It looks like you can't use decimal numbers for the exponent. There is a bcsqrt() function, though. Quote Link to comment Share on other sites More sharing options...
utexas_pjm Posted June 16, 2007 Share Posted June 16, 2007 It makes more sense to use fractions anyway -- as x^(1/k) is the kth root of x. Just create a function like: <?php function root($x, $k) { return( ($x < 0 && $k % 2 > 0 ) ? -1 : 1 ) * pow(abs($x), 1/$k); } ?> Best, Patrick Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 16, 2007 Share Posted June 16, 2007 Eh, (a) I don't think that's arbitrary precision, and (b) 1/x is still evaluated as a non-integer. Maybe there's an identity you can find to circumvent that limitation or a homemade function that will do what you want. Quote Link to comment Share on other sites More sharing options...
utexas_pjm Posted June 16, 2007 Share Posted June 16, 2007 Oops, sorry I missed the arbitrary precision requirement. Just FYI -- You can use non integer exponents in the pow() function. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.