MIPS Instruction programming

  • Thread starter rictor
  • Start date
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:
https://gist.github.com/dcalacci/3747521
 

Attachments

BvU

Science Advisor
Homework Helper
12,098
2,668
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
 

rbelli1

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

BoB
 

Want to reply to this thread?

"MIPS Instruction programming" You must log in or register to reply here.

Related Threads for: MIPS Instruction programming

D
Replies
1
Views
4K
  • Posted
Replies
5
Views
6K
  • Posted
Replies
2
Views
2K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving

Hot Threads

Top