Gentlemen, I need to count a certain percentage of a certain number, for example, 6% of 100. I tried to do so. Divided the number by 100, and multiplied by the percentage, but the result was wrong when the number is less than 100. Here's how to calculate it?

  • 3
    Operations on integers? If so, first multiply the number by a percentage, and then divide by 100. The error will be less. - alexlz
  • 2
    You probably used the usual integer division? It is necessary to use operations on a variable with a floating point. For example, read about arithmetic coprocessor. - skegg
  • In addition to the @mikillskegg comment. And if there is no coprocessor (not x86, up to 486sx, or up to 386dx without a coprocessor), then use the library for floating point operations. - alexlz
  • The @mikillskegg coprocessor is, of course, good, but not in the student lab @alexlz yes, integers. Thanks for the answer, your method worked. The fractional part, I think, can be omitted - Xanx
  • 2
    By the way, after dividing by 100 (idivl instruction) the fractional part will be in the% edx register. You can immediately use. - avp

0