Literals/Floating point: Difference between revisions
Content deleted Content added
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 837: | Line 837: | ||
bfloat(%pi); |
bfloat(%pi); |
||
3.141592653589793238462643383279502884197b0</lang> |
3.141592653589793238462643383279502884197b0</lang> |
||
=={{header|MIPS Assembly}}== |
|||
Ultimately it depends on the assembler, however, it's standard to allow simple expressions like "2.5". Since MIPS uses a floating-point coprocessor with separate registers, the assembler understands that you're trying to load a float into the register rather than an integer, and so the assembler will calculate the IEEE-754 hexadecimal representation for you. |
|||
<lang mips>li.s f0,2.5 ;loads the single-precision float 2.5 (0x40200000) into register f0</lang> |
|||
Defining literal float data in your code also depends on the assembler. If all else fails, you can use a calculator to get the IEEE-754 hexadecimal representation of the desired float and store it as an "integer." |
|||
<lang mips>la $t0,pi |
|||
lwc1 $f0,0($t0) ;load pi into $f0 |
|||
li $v0,10 ;exit command |
|||
syscall ;return to linux |
|||
pi: |
|||
.word 0x40490FDB ;IEEE-754 representation of 3.1415927</lang> |
|||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |