Abdou Bestmood
Abdou Bestmood

Reputation: 485

Dealing with large numbers in php

$k = bcmul(PHP_INT_MAX ,PHP_INT_MAX);
echo number_format($k,0,'','');

How can I display the exact result of $k?

I know that php converts an integer into a float whenever it exceeds the maximum value but I still don't get the right result from the above multiplication.

Upvotes: 0

Views: 100

Answers (2)

MonkeyZeus
MonkeyZeus

Reputation: 20737

Why do you need number_format($k,0,'','');??

Just:

echo bcmul(PHP_INT_MAX ,PHP_INT_MAX);

Upvotes: 2

symques
symques

Reputation: 46

Print the value as string (reference: http://php.net/manual/en/function.bcmul.php#110658)

printf('%s', $k);

Upvotes: -1

Related Questions