Problems with a long integer

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
cluster28
Forum Newbie
Posts: 10
Joined: Mon May 24, 2010 5:29 am

Problems with a long integer

Post by cluster28 »

I have a WSDL that it returns this field:

<xsd:element maxOccurs="1" minOccurs="1" name="CO-RFR-AVE-ICD-TDE" nillable="false" type="xsd:long"/>

The field content returned is 20110094012838001.

I made an echo and the result was 2.01100940128E+16.

How can i display the field content correctly?

I´ve tried

Code: Select all

 
(string)$field
settype($field,'string')
$string_field='-'.$field
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Problems with a long integer

Post by Weirdan »

You can display it like this:

Code: Select all

printf("%.0f", $number);
However you cannot expect it to work like an integer because it exceeds integer range for you platform (32bit). Maximum positive integer PHP can treat as a native integer is likely 2147483648 in your case.
Post Reply