go to previous page   go to home page   go to next page highlighting

Answer:

Of course. The various bit manipultion instructions could be used for this.

Early microprocessors had no direct support for floating point and such manipulation was common.


Converting Between Number Formats

InstructionOperation
cvt.s.w fs, fw

Convert the 32-bit integer in float register $fw
to an IEEE float in register $fs

cvt.w.s fw, fs

Convert the 32-bit float in register $fs
to an integer in float register $fw

the "w" means 32-bit integer full word.
the "s" means 32-bit single precision.

High level languages allow you to write statments like this:

float val = 1.0 + 1;

The operands are of mixed types. The statement compiles into machine operations that convert the integer into floating point and perform a floating point addition. Operations are always between data of the same type, even when that is not what the programmer wrote.

Rather than use bit manipulation instructions to convert an integer to floating point, MIPS (and QtSpim) has machine instructions that do this.

There are other instructions that convert between double precision and other data types, but we will not use them.


QUESTION 22:

Is it possible to lose accuracy when converting a 32-bit integer into a 32-bit IEEE float?


go to previous page   go to home page   go to next page