RE: Problem with HUGE floating values and fmod

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



THANKS!

That did the trick.

For future reference to all people needing to calculate check digits with
ISO 7604 (MOD 97-10) method:

$check=98-bcmod(($num."00"),97);

The ."00" part is imporant... If $num was multiplied by 100 we wouldn't get
a correct value in bcmod. 


Marco Almeida
Project Manager

WEBDADOS
Tecnologias de Informação

Telef.:	 +351 21 466 93 00	
Fax:	 +351 21 466 42 81	
Móvel:	 +351 96 324 43 44	
Email:	 marcoalmeida@xxxxxxxxxxx	
www:	 http://www.webdados.pt	
Morada:	 R. 9 de Abril, 3-3A, Sala 4
2765-545 S. Pedro do Estoril	

-----Original Message-----
From: Curt Zirzow [mailto:czirzow@xxxxxxxxx] 
Sent: sexta-feira, 17 de Fevereiro de 2006 20:40
To: php-general@xxxxxxxxxxxxx; marcoalmeida@xxxxxxxxxxx
Subject: Re:  Problem with HUGE floating values and fmod

On Fri, Feb 17, 2006 at 06:48:13PM -0000, Marco Almeida wrote:
> Hi there,
>  
> I'm trying to calculate check digits for a payment system, using the 
> ISO
> 7064 (MOD 97-10) algorithm, wich is, already translated to PHP:
> 
> $check=98-fmod(($num*100),97);
> 
> Where $num is a huge number...
> 
> Example: 90150123123400043211 should have check digit 51 In windows 
> calculator: 98 - ( (90150123123400043211 * 100) mod 97) works OK and I 
> get 51 as result
>
> In PHP I get 13...

You will need to use GMP or BCMath to do math operations numbers that size.

See:
http://php.net/language.types.integer.php


Curt.
--
cat .signature: No such file or directory

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux