473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

division by zero after PHP-Upgrade

Hi.

I have following problem after my hoster updated to PHP 5.2.1. I'm not
really sure from what Version the update was done, but it was
definetly something like 5.x.x.
Locally I run XAMPP w/ PHP 4.4.4 and my script runs just fine.

These are the two lines which generate the error.
$return = $sbox0[$b0] + $sbox1[$b1] % pow(2,32) ;
$return = ($return ^ $sbox2[$b2]) + $sbox3[$b3] % pow(2,32);
It doesn't matter what is stored in the sboxes since the error has to
be from the modulo.

I tested if pow(2,32) would generate a zero, but it doesn't. So that
can't be the problem.

I use @() and the script seems to work.

Any suggestions?

Mar 8 '07 #1
3 1789
Cord-Heinrich Pahlmann wrote:
These are the two lines which generate the error.
$return = $sbox0[$b0] + $sbox1[$b1] % pow(2,32) ;
Modulus with big number is buggy (bug reports 1335, 12623, 25328). You
could use BCmath or the following function:

function mod($a, $b) {
return $a - $b * floor($a / $b);
}

Sjoerd
Mar 8 '07 #2
On 8 Mrz., 14:16, Sjoerd <sjoerd-n...@linuxonly.nlwrote:
Cord-Heinrich Pahlmann wrote:
These are the two lines which generate the error.
$return = $sbox0[$b0] + $sbox1[$b1] % pow(2,32) ;

Modulus with big number is buggy (bug reports 1335, 12623, 25328). You
could use BCmath or the following function:

function mod($a, $b) {
return $a - $b * floor($a / $b);

}

Sjoerd
It returns different values. bcmod() also doesn't return the right
ones.
I guess I have to stick with @();

Mar 8 '07 #3
"Cord-Heinrich Pahlmann" <SP**@Heineken2000.dewrote in message
news:11**********************@64g2000cwx.googlegro ups.com...
I use @() and the script seems to work.

"seems to work" as in "it doesn't produce error notices anymore". I'd like
to know if there was actually difference in error reporting level between
old and new install. Maybe the problem has existed in the previous version
as well, it just hasn't echoed any warnings about it because of different
error reporting settings.

Suppressing error messages is not fixing a problem if you ask me. If there
in fact is a bug then you should do something about it, not just pretend
it's not there. Also, using pow(2,32) as a constant is dumb, you should
calculate the real value of it (ie. 4294967296) and use that, always
calculating the value of a constant just uses unnecessary computer cycles
and slows down the performance a tad.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Mar 9 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: florian.boldt | last post by:
Hi Folks, one of our developers uses a statement with a where clause which usually does not match to any rows. In case of one or more rows found she wrote a an expression in the select clause...
6
by: bart van deun | last post by:
Hello, i have a problem with a division by zero fault in my report trough a query... this is the expression in the query: Name: Sum(IIF(=0,0,/)) what is wrong with this expression?
9
by: Marcin | last post by:
How I can make division of two numbers placed in arrays, example: short int a = {2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2}; short int b =...
16
by: Greg Donald | last post by:
Converting some MySQL code to work with Postgres here. I have this query: SELECT tasks.task_id, (tasks.task_duration * tasks.task_duration_type / count(user_tasks.task_id)) as...
2
by: subnunciation | last post by:
i know, this shouldnt be a conundrum right? one just shouldnt divide by zero. but this is suddenly happening *all over* my site. after chasing the error here and there, i simplified things down to:...
10
by: Mike S | last post by:
Does anyone know the logic behind why in VB.NET the result of a floating-point division ('/') is -rounded- on being converted to an integer type, such as with statements like Dim x As Integer =...
2
by: Pakna | last post by:
Why do I have a zero result on this query for all non-zero rows? Do I have to declare specifically the precision of ratio division? How do I do that? And is there a way to make DB2 'ignore'...
94
by: krypto.wizard | last post by:
Last month I appeared for an interview with EA sports and they asked me this question. How would you divide a number by 7 without using division operator ? I did by doing a subtraction and...
9
by: Joe Cool | last post by:
Hello, I am using VS2005. I am trying to convert a VB.NET app to C#.NET. The VB app uses a progress meter to indiate how far a file has been read. I use the following assignment statement in VB: ...
2
by: cobolman | last post by:
I've got the following SQL SELECT count(*) FROM tablea A JOIN tableb B ON ..etc.. WHERE a.string_val = 'test' AND b.divider 0 AND a.number 0 AND (a.number / b.divider 0) The b.divider...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.