Reputation: 4170
Can somebody tell me please why this code
returns double
in php
?
$personal_id = ((int) $person['born_number'] * 2);
Gettype($personal_id)
returns double
like this 4294967294.0
How can I solve this? Thanks.
Upvotes: 1
Views: 149
Reputation: 41
Why double? Because variable doens't fit into integer size.
You may use gmp for emulating big integer. http://php.net/manual/en/intro.gmp.php
But i think it's overengineering. What if use string instead of integer?
$personalId = sprintf("%.0f", ($a*2));
Upvotes: 1
Reputation: 1105
Maybe you should try intval()
(cf. official documentation)
$personal_id = intval($person['born_number'] * 2);
Upvotes: 0