vim-crunch icon indicating copy to clipboard operation
vim-crunch copied to clipboard

modular arithmetic fails

Open Konfekt opened this issue 6 years ago • 2 comments

default conversion of all numbers to floating point by appending .0 to integers makes modular arithmetic fail, for example, 10 % 3 produces the error messages

Errore/i eseguendo function crunch#operator[47]..crunch#eval[29]..crunch#core[6]
..<SNR>372_eval_math[10]..<SNR>372_vim_eval:
riga    8:
E804: Non si può usare '%' con un Numero-a-virgola-mobile
E15: Espressione non valida: 10.0 % 3.0

instead of 10 % 3 = 1.

Konfekt avatar Dec 25 '19 16:12 Konfekt

yes this is unfortunate side effect of the implementation that converts all numbers into floats implicitly, so in addition to module functions like or() and and() that only take integers also don't work.

arecarn avatar Dec 26 '19 17:12 arecarn

In practice, it might be safe to drop this conversion as soon as mod and alike appear. I've never seen modular and floating point arithmetic mixed together.

Konfekt avatar Dec 26 '19 18:12 Konfekt

closing as I don't plan on adding support for this.

arecarn avatar Dec 05 '23 18:12 arecarn