i'm confused properties of modulo (mod) operator in different bases. i'm calculating 23010 % 1110 = 1010. if switched base 16, e616 % b16 = a16? number system's base matter mod operation?
(note: i'm using little calculator app in javascript i'm writing, don't see why language should matter.)
the modulo (mod) operator means take remainder after division. value of remainder not depend on base. computer uses binary. when input or display number base matter.
in other words, base how value displayed. consider number represented roman numeral x. display 10 in decimal (base ten), or 1010 in binary. if divide roman numeral iv (4 decimal or 0100 binary), remainder of roman numeral ii, or 2 in decimal, or 0010 in binary.
in summary, values in 3 equations same - display changes:
x mod iv = ii // roman numerals 10 mod 4 = 2 // base ten (decimal) 1010 mod 0100 = 0010 // binary
for clarity user, want require operands , mod result in same base.
Comments
Post a Comment