bcmod() behavior is different from what I expected

php.internals

Saki Takamachi

2 years ago
Hi internals, I noticed that `bcmod()` behavior is a little different from what I expected. First, look at the following code for `bcdiv()`: ``` bcdiv('99', '100', 2); // '0.99' ``` So what should the following code be? ``` bcmod('99', '100', 2); ``` The result is `'99.00'`. I was expecting `'0.00'` for this. I thought that if gave `bcdiv()` and `bcmod()` the exact same arguments, their results would not contradict each other. To me this is unexpected behaviour, how do you think? Regards, Saki

Saki Takamachi

2 years ago
> Hi internals, > > I noticed that `bcmod()` behavior is a little different from what I expected. > > First, look at the following code for `bcdiv()`: > ``` > bcdiv('99', '100', 2); // '0.99' > ``` > > So what should the following code be? > ``` > bcmod('99', '100', 2); > ``` > > The result is `'99.00'`. > I was expecting `'0.00'` for this. I thought that if gave `bcdiv()` and `bcmod()` the exact same arguments, their results would not contradict each other. > > To me this is unexpected behaviour, how do you think? > > Regards, > > Saki
However, considering the behavior of `fdiv()` and `fmod()`, the current behavior of `bcmod()`may be correct and my thinking may be wrong... Saki

Saki Takamachi

2 years ago
>> Hi internals, >> >> I noticed that `bcmod()` behavior is a little different from what I expected. >> >> First, look at the following code for `bcdiv()`: >> ``` >> bcdiv('99', '100', 2); // '0.99' >> ``` >> >> So what should the following code be? >> ``` >> bcmod('99', '100', 2); >> ``` >> >> The result is `'99.00'`. >> I was expecting `'0.00'` for this. I thought that if gave `bcdiv()` and `bcmod()` the exact same arguments, their results would not contradict each other. >> >> To me this is unexpected behaviour, how do you think? >> >> Regards, >> >> Saki > > However, considering the behavior of `fdiv()` and `fmod()`, the current behavior of `bcmod()`may be correct and my thinking may be wrong... > > Saki
I was probably tired. Please forget about this thread... Saki