Jump to content

MIPS Integer to Decimal(Fraction)/Percent

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
acm1

acm1

    Newbie

  • Members
  • Pip
  • 1 posts
I am making an interest calculation program and can't figure out how to get the integer number input by the user into a decimal number. For example I don't know how to make 5, into .05 in MIPS assembly language. I've tried div but I can't get it to work I'll include my code for it. Any help is greatly appreciated.

**In $s1 is the value 5

	li	$t3,	100

	div	$s1,	$t3

	mfhi	$s1


#2
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
You can't put a decimal number into an integer variable, as the decimal part is thrown. Try using a decimal variable in the first place. I don't know any MIPS, but if you're using a modern .NET language, it's simple:

(C#)

int i = 5;
decimal d = (decimal) (i / 100.0);
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums