Description:
SELECT 0.00000000042 mod 1;
+---------------------+
| 0.42000000000 |
+---------------------+
SELECT 0.000000000123 mod 0.000000000030;
+-----------------------------------+
| 0.003000000000 |
+-----------------------------------+
These are the right answers, but all multiplied by 1e9. (This is not completely surprising if you know how MySQL represents decimals internally.)
Anything with 0 through 8 leading zeros works fine; the bug starts at 9 leading zeros. There are discontinuities at 17, 26, 35,... leading zeros where sanity is briefly restored.
How to repeat:
create table t (id serial, d decimal(65,30));
insert into t values (),(),(),(),(),(),(),(),();
insert into t values (),(),(),(),(),(),(),(),();
insert into t values (),(),(),(),(),(),(),(),();
update t set d = concat('1e-', id);
select d, d mod 1 from t;
+----------------------------------+----------------------------------+
| d | d mod 1 |
+----------------------------------+----------------------------------+
| 0.100000000000000000000000000000 | 0.100000000000000000000000000000 |
| 0.010000000000000000000000000000 | 0.010000000000000000000000000000 |
| 0.001000000000000000000000000000 | 0.001000000000000000000000000000 |
| 0.000100000000000000000000000000 | 0.000100000000000000000000000000 |
| 0.000010000000000000000000000000 | 0.000010000000000000000000000000 |
| 0.000001000000000000000000000000 | 0.000001000000000000000000000000 |
| 0.000000100000000000000000000000 | 0.000000100000000000000000000000 |
| 0.000000010000000000000000000000 | 0.000000010000000000000000000000 |
| 0.000000001000000000000000000000 | 0.000000001000000000000000000000 |
| 0.000000000100000000000000000000 | 0.100000000000000000000000000000 |
| 0.000000000010000000000000000000 | 0.010000000000000000000000000000 |
| 0.000000000001000000000000000000 | 0.001000000000000000000000000000 |
| 0.000000000000100000000000000000 | 0.000100000000000000000000000000 |
| 0.000000000000010000000000000000 | 0.000010000000000000000000000000 |
| 0.000000000000001000000000000000 | 0.000001000000000000000000000000 |
| 0.000000000000000100000000000000 | 0.000000100000000000000000000000 |
| 0.000000000000000010000000000000 | 0.000000010000000000000000000000 |
| 0.000000000000000001000000000000 | 0.000000000000000001000000000000 |
| 0.000000000000000000100000000000 | 0.000000000100000000000000000000 |
| 0.000000000000000000010000000000 | 0.000000000010000000000000000000 |
| 0.000000000000000000001000000000 | 0.000000000001000000000000000000 |
| 0.000000000000000000000100000000 | 0.000000000000100000000000000000 |
| 0.000000000000000000000010000000 | 0.000000000000010000000000000000 |
| 0.000000000000000000000001000000 | 0.000000000000001000000000000000 |
| 0.000000000000000000000000100000 | 0.000000000000000100000000000000 |
| 0.000000000000000000000000010000 | 0.000000000000000010000000000000 |
| 0.000000000000000000000000001000 | 0.000000000000000000000000001000 |
+----------------------------------+----------------------------------+