Problems with numbers with Scientific notation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iceangel89
Forum Commoner
Posts: 39
Joined: Mon Jul 02, 2007 7:02 pm

Problems with numbers with Scientific notation

Post by iceangel89 »

i noticed that when there is Scientific noted numbers, math operators like +/-/MOd etc dont work. how do i fix this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

example?
iceangel89
Forum Commoner
Posts: 39
Joined: Mon Jul 02, 2007 7:02 pm

Post by iceangel89 »

ok i done a example here, with the relavent php code displayed ... i put it here too

http://fusion-planet.updownloading.com/ ... roblem.php

Code: Select all

<?php
$answer = 0;
$ansMod = 0;
if (isset($_POST['num1']) and isset($_POST['num2'])) {
	$num1 = $_POST['num1'];
	$num2 = $_POST['num2'];
	$answer = pow($num1, $num2);
	$ansMod = $answer % 123;
}
?>
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

From what I know PHP doesn' t have a function\ class that supports big numbers like Java. Do add, multiply, divide you have to use arrays and the rules of that operation.
Make a function that reads the string that user put , put it in an array (use strpos in a for) then do the mathematical operations using their rules.
P.S. It' s not easy. If you want to work with big numbers I wouldn' t do it in PHP. Use Java or a faster language.
Post Reply