GNU BC: How is the “modulo” (%) with scale other than 0 useful?
0
votes
2
answers
1792
views
This is a **self-answered** question, the research that is reasonable to ask for a question goes in the answer part, Please do not downvote because you believe I have not researched enough for an answer. Thanks. In any case, there is no description (that I can find) of this characteristic of bc in this site.
When using
bc
, the %
operator is claimed to calculate the "remainder", and yes, it works for integer numbers and when the **scale is zero**:
$ bc <<<' scale=0; 27 % 7 '
6
But it fails to give the "integer remainder" if the scale is not zero:
$ bc <<<' scale=10; 27 % 7 '
.0000000003
Why (or how) is this definition of the %
modulo useful?
Asked by user232326
Oct 28, 2018, 02:02 AM
Last activity: Nov 25, 2024, 10:48 PM
Last activity: Nov 25, 2024, 10:48 PM