Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MIPS Instruction programming

  1. Nov 10, 2016 #1
    when I try to compile the MIPS instruction in order to compute the factorial of n number? i get the following error in the console as:
    Enter the factorial number: 20
    factorial of given number: -2102132736
    The output which I am getting as negative integer of a given factorial instead of positive integer.
    The program for the given MIPS instructions is seen in the link below:

    Attached Files:

  2. jcsd
  3. Nov 10, 2016 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Looks like a size or a formatting problem:
    2102132736 is 31 bits and -2102132736 is 32 bits interpreted as a 4 byte integer (first bit a sign bit)

    For 20! you need more than 62 bits
  4. Nov 14, 2016 #3


    User Avatar
    Gold Member

    20! truncated to 32 bits is -2102132736. It looks like you are calculating to 64 bits then displaying 32 bits.

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted

Similar Discussions: MIPS Instruction programming
  1. Robotics Program (Replies: 5)

  2. Programming OPLCs (Replies: 0)