what is READ_FLT? any thoughts on the question?

If a program employs a READ_FLT syscall to input the floating point value 999999999999.0, by how much would the value returned by the syscall differ from the actual value typed in? Explain the error, if any.

helloooooooooo

Won't work the way you think!

A float is 32-bit so only have about 4-5 digits of precision. That number is WAY TOO BIG! So it will definitely be put into exponential form provided the buffer is large enough! It also depends upon how long a buffer is acceptable!

i am getting following when inputting 999999999999.0:
999999995904.0

so difference is
999999999999.0-999999995904.0 = 4095

why is this? why am I not getting the error you are talking about? here is my code:

``````.data
prompt:	 .asciiz "Please enter a (floating point) number: "
plus:	 .asciiz " + "
equals:	 .asciiz " = "
nl:	 .asciiz "\n"

.text 0x00400000
.globl main
main:
la \$a0, prompt
li \$v0, 4	#print_string
syscall

syscall
mov.s \$f1, \$f0

li \$v0, 2	#print_float
mov.s \$f12, \$f0
syscall

mfc1 \$s0, \$f0
mfc1 \$s1, \$f1
mfc1 \$s2, \$f2

li \$v0, 10	#exit
syscall``````

You are getting exactly the error I'm talking about! That's one of the reason you do not use floating-point for accounting as you lose pennies! That's why for accounting application its best to used fixed point or BCD math.

You are getting a loss of precision! Only it is being displayed in normal floating-point instead of in its exponential form!

According to your other post you mention entering integers with that many digits and parsing each digit. Why are you now entering as a Single-Precision Floating-Point value and having the system call do the work for you? Do it the way you originally indicated as an integer. If you like, handle a carry type operation into two 32-bit values so as to handle a bigger number!

To rectify your problem and have the system do the work for you, you need to enter a 64-bit Double-Precision Floating-Point value, or an 80-bit Extended Double-Precision Floating-Point Value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.