We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,374 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Large Numbers Problem

Well, I'm making this script that deals with numbers that can go up to some VERY large numbers.
Like 1.0E+150

I have tried

<?php
echo number_format(1.0E+10);
?>

But that returns 10,000,000,000
I want a way to show that number, but without the comas.

Can anyone help?

3
Contributors
3
Replies
1 Hour
Discussion Span
3 Years Ago
Last Updated
4
Views
Question
Answered
DealthRune
Light Poster
45 posts since Apr 2009
Reputation Points: 12
Solved Threads: 0
Skill Endorsements: 0

try this

echo number_format(1.0E+10, 0, '', '');
hashinclude
Junior Poster
111 posts since May 2007
Reputation Points: 11
Solved Threads: 8
Skill Endorsements: 0

Why not use the following?

$number='10000000000';
echo $number.'<br>';
//now some math
echo bcadd($number,'500');
echo '<br>';
echo bcpow('2','2048');

As you can see all numbers can be dealt with as strings using the bcmath library. So this means the size of the number is only limited to the computers ram and cpu instead of 2^63 or 2^31.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 260
Skill Endorsements: 13
Question Answered as of 3 Years Ago by cwarn23 and hashinclude

Thanks cwarn, but I think hashinclude's way is better, considering I'm using a mysql_fetch_assoc() method.

DealthRune
Light Poster
45 posts since Apr 2009
Reputation Points: 12
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0815 seconds using 2.76MB