note 94487 deleted from function.gettype by danbrown
| From: | danbrown@php.net | Date: | Sun, 08 Nov 2009 16:20:05 +0000 |
| Subject: | note 94487 deleted from function.gettype by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162643@lists.php.net to get a copy of this message | ||
Note Submitter: Stratadrake
----
Re: Andaramuxo, that's actually not a bug. pow() operates in floating-point by default -- it
will return an integer "if possible", but this is based on whether its operands were
integers or floats and not on whether the result actually has a fractional component. Pass
floating-point numbers to pow(), you will always get a floating-point result.
For example:
<?php
$x = pow(4, 2); // integer operands
echo gettype($x); // 'integer'
$y = pow(4.0, 2); // mixed operands
echo gettype($y); // 'double'
$z = pow(4.0, 2.0); // float operands
echo gettype($z); // 'double'
?>