mips associative floating point -
okay testing have code
.data # shows can use .word , directly encode value in hex # if choose num1: .word 0x3f800000 num2: .float 1234.567 num3: .float 45.67834 num4: .float 0.0004 result: .word 0 string: .asciiz "\n" .text main: la $t0, num1 lwc1 $f2, 4($t0) lwc1 $f4, 8($t0) lwc1 $f6, 12($t0) # print out values of summands li $v0, 2 mov.s $f12, $f2 syscall li $v0, 4 la $a0, string syscall li $v0, 2 mov.s $f12, $f4 syscall li $v0, 4 la $a0, string syscall li $v0, 4 la $a0, string syscall # actual addition add.s $f12, $f2, $f6 add.s $f12, $f12, $f4 # transfer value floating point reg integer reg swc1 $f12, 8($t0) lw $s0, 8($t0) # @ point, $f12 holds sum, , $s0 holds sum can # read in hexadecimal li $v0, 2 syscall li $v0, 4 la $a0, string syscall # jr crashes mars # jr $ra
i have this
add.s $f12, $f2, $f6 add.s $f12, $f12, $f4
i tried swapping order say
add.s $f12, $f4, $f6 add.s $f12, $f12, $f2
but result same
i checked wikipedia examples of floating point additions arent same, comes 1280.2457
http://en.wikipedia.org/wiki/floating_point
they had happen:
= 1234.567, b = 45.67834, c = 0.0004 (a + b) + c: 1234.567 (a) + 45.67834 (b) ____________ 1280.24534 rounds 1280.245 1280.245 (a + b) + 0.0004 (c) ____________ 1280.2454 rounds 1280.245 <--- (a + b) + c + (b + c): 45.67834 (b) + 0.0004 (c) ____________ 45.67874 1234.567 (a) + 45.67874 (b + c) ____________ 1280.24574 rounds 1280.246 <--- + (b + c)
didn't hapepn me works values try
nm, got it
a=0.00004 b=45.67840 c=1234.567
Comments
Post a Comment