Properly use integers in exponentiation

Right now they're always float.

Bug: T191688
Depends-On: I398c9a972b7e9fcb27d055d23939be2b8bb68244
Change-Id: I0bb1ed0109af66997e238b532d342d82d4c4ae19
This commit is contained in:
Daimona Eaytoy 2018-04-07 14:01:17 +02:00
parent 2dda2e381c
commit 3e9a2dfd33

View file

@ -136,7 +136,12 @@ class AFPData {
* @return AFPData
*/
public static function pow( $base, $exponent ) {
return new AFPData( self::DFLOAT, pow( $base->toFloat(), $exponent->toFloat() ) );
$res = pow( $base->toNumber(), $exponent->toNumber() );
if ( $res === (int)$res ) {
return new AFPData( self::DINT, $res );
} else {
return new AFPData( self::DFLOAT, $res );
}
}
/**