Jul 26, 2008

Outputting Large Numbers

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Outputting Large Numbers

beeseven
Usually when you output a large number (>14 digits), it takes it and turns it into an exponential expression (eg: 1.6E+15). Is there a way to change it so that it doesn't turn it into that and just keeps outputting all the digits?

Reply

Spectre
The first two options that spring to mind would be assigning the value to a string variable type, or using the number_format() function (which returns the value as a string, and also groups the digits in blocks of three seperated by a comma, by default).

For example:
CODE
// If printed, would display '1.e+14'
$number = 100000000000000;
// If printed, would display the value as a string, exactly as you see it
// (the quotes indicate a string value)
$number = '100000000000000';
// If printed, would display the number with digit grouping
$number = number_format(1.e+14);


Hope that explains things for you.

Reply

beeseven
Number format is good, I just used number_format($n,0,'','') the separator '', which achieved the desired affect.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : outputting numbers

  1. Showing Numbers Of Mysql Entries In A Database Table - It should be easy, but I don't know how... (7)
  2. Showing Numbers With Mysql - (5)
    I have a int column with numbers, and I want to show only the numbers between 5 and 20 in that
    column. So my list would be like this: CODE 5 7 15 16 I know how to only show numbers that
    are less than 20 or greater than 5, but I can't manage to combine those two (Less than 20 AND
    greater than 5). So I guess it would be something like this: CODE SELECT * FROM `table`
    WHERE `introw` >= 5 && <= 20 How can I do that?...
  3. Ordering Numbers With Mysql? - (4)
    I am making a MySQL-driven list. It can be ordered by name or by a number in the table. However, it
    orders the numbers like this: CODE 1 2 23 3 456 7 9 98 But I want the numbers to be ordered
    like this: CODE 1 2 3 7 9 23 98 456 How can I do that?...



Looking for outputting, large, numbers

Searching Video's for outputting, large, numbers
advertisement



Outputting Large Numbers



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE