FG
💻 Software

GNU BC: "modulo" % with scale other than 0

Fresh5 days ago
Mar 15, 202621121 views
Confidence Score0%
0%

Problem

If the scale is other than zero, calculations with %, such as 3%2 and 46%4, tend to output 0. How is the algorithm designed with the scale other than 0?

Error Output

bc
scale=10
print 4%3   // output 0

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: GNU BC: "modulo" % with scale other than 0

Low Risk

The command manual says this about how BC calculates the modulo: The result of the expression is the "remainder" and it is computed in the following way. To compute a%b, first a/b is computed to scale digits. That result is used to compute a - ( a/b…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment