Question

J'utilise bcmath pour faire des maths avec 64 bits entiers non signés, je veux faire un bcmath objet à un int normal (haute, partie basse) Comment puis-je y parvenir?

Merci pour votre aide

Était-ce utile?

La solution

Les fonctions de bcmath ne traitent pas encastrables avec BCMath objets en tant que tels, ils ont juste processus sur les chaînes pour réaliser le calcul de précision arbitraire. Ainsi, vous pouvez reconvertir en un int php natif avec une distribution normale.

$val = (int) bcmod( bcpow( "9392", "394" ), "100" );

De http://php.net/manual/en/book.bc.php , les signatures de méthode sont

string bcmod ( string $left_operand , string $modulus )
string bcpow ( string $left_operand , string $right_operand [, int $scale ] )
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top