You are here: Re: Differentr Values for intval(float) « PHP Programming Language « IT news, forums, messages
Re: Differentr Values for intval(float)

Posted by Jasen Betts on 02/19/06 06:03

On 2006-02-18, Bruce <bvanderweb@gmail.com> wrote:
> Consider the following code:
>
> $BB = -2181087916;
> $AA = (int)$BB;
> $AA = intval($BB);
>
> On some systems, $AA will be int(-2147483648), which is actually
> consistent with the documentation.
>
> On most systems, however, $AA will be int(2113879380), which is the
> same value truncated at 32 bits.
>
> I actually need the latter behavior, as it needs to duplicate Delphi
> code, which, like C, behaves the same way.
>
> This is encryption code that does a bunch of calculations on signed
> 32-bit numbers and ignores any overflows.
>
> Any ideas how I can do this?

after that do this.

$AA= (( $AA + 2147483648 ) & 4294967295) - 2147483648 ;

it should give the result you want on 64-bit machines
and be harmless on 32-bit machines.

Bye.
Jasen

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация