# bcmod() behavior is different from what I expected

- Thread: https://externals.io/message/124551
- Original archive: https://news-web.php.net/php.internals/124551
- Started by Saki Takamachi on 2024-07-23T03:01:47+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #124551 — Saki Takamachi — 2024-07-23T03:01:47+00:00

URL: https://externals.io/message/124551#124551

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

---

## #124552 — Saki Takamachi — 2024-07-23T03:10:42+00:00

URL: https://externals.io/message/124551#124552 · In reply to: #124551

> ﻿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

---

## #124553 — Saki Takamachi — 2024-07-23T06:27:59+00:00

URL: https://externals.io/message/124551#124553 · In reply to: #124552

> > […]
> 
> 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
