PDA

View Full Version : Multiplying In Php



vivitron 15
02-26-2004, 12:15 AM
I have a project which relies on a php form multiplying 2 large numbers but Im having a problem with the output:


Originally posted by my_code

<? &#036;number1=123456789012;
&#036;number2 = 9876543214327;
&#036;numbertotal=&#036;number1*&#036;number2;

&#036;shouldbe=1219326311779068734574924;

print(&#036;numbertotal . "
" . &#036;shouldbe);

if (&#036;numbertotal==&#036;shouldbe) {
&nbsp; &nbsp; print("
YES");
} else {
&nbsp; &nbsp; print("
NO");
};

?>

now the output i get is &#036;numbertotal=1.21932 E 24 and NO.

anyone know how i get rid of the exponential description and get it expressed as a simple integer?

NightStalker
02-26-2004, 01:08 AM
&#60;?php
&#036;numone=123456789012;
&#036;numtwo = 9876543214327;
echo bcmul&#40;&#036;numtwo, &#036;numone&#41; . &#34;&#092;n&#34;;
?&#62;

vivitron 15
02-26-2004, 01:25 AM
when i try this i get no output - just a blank screen :frusty:

NightStalker
02-26-2004, 01:59 AM
You will prboally need to install BCMath..

http://php.us.themoes.org/manual/en/ref.bc.php

vivitron 15
02-26-2004, 08:48 AM
ah, k thanks...

Ill have to speak with my ISP i guess :)