Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (2.6k points)
recategorized by
Could anybody solve this query? MySQL MOD() is broken: Is this the best alternative to explain?

1 Answer

0 votes
by (7.2k points)

 k = x - n * trunc(x / n)

Where you are expecting the implementation to use floored division:

k = x - n * floor(x / n)

Since this is how you implemented your first workaround, I'd say it's probably the best alternative to the Mod operator.

 

 

It seems like more imperative programming languages implement truncated division and more functional mathematical languages seem to use floored division.

Related questions

0 votes
1 answer
asked Jan 5, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...