Hello,

I've searched through the board and in the Raymond's tutorials but I wasn't able to find an answer...

Is there a way to know if a number, currently retained on the FPU, has a decimal part (I mean "something after the '.').

For example, my program take a number inputed by user, then compute the square root of this number.

user input : 100

result: 10. (no decimal part here)

user input : 99

result: 9.94987... (decimal part here)

I've looked for the status and control words, but it seems they can't tell me if there's a decimal part.

What should I do ?

Thank you very much.

Regards, Neitsa.

I've searched through the board and in the Raymond's tutorials but I wasn't able to find an answer...

Is there a way to know if a number, currently retained on the FPU, has a decimal part (I mean "something after the '.').

For example, my program take a number inputed by user, then compute the square root of this number.

user input : 100

result: 10. (no decimal part here)

user input : 99

result: 9.94987... (decimal part here)

I've looked for the status and control words, but it seems they can't tell me if there's a decimal part.

What should I do ?

Thank you very much.

Regards, Neitsa.

Need to round number to integer and subtract to get fractional part.

Instruction FRNDINT should work.

Instruction FRNDINT should work.

i used this code (from delphi rtl)

when i needed to do the same thing

when i needed to do the same thing

```
fld st
```

push 1F320000h

fnstcw [esp]

fldcw [esp+2]

frndint

fldcw [esp]

fsub

fldz

fcompp

add esp,4

fnstsw ax

sahf

je nothing after the '.'

Maybe you're already aware of this but I feel the need to point out that because of the impercission of finite machines some numbers which you may load into the FPU as integers will end up haveing a small decimal bit.

If you are programming for the Pentiums or higher, you could use the following. From the tutorial, you will understand the idea. Assuming the number you want to examine is already in ST(0) and ST(7) is still free:

All the FPU data registers are still in the same state as before the above code. Good enough? Just make sure to use the .686 directive to assemble.

Raymond

```
fld st ;make copy
```

frndint ;round it to an integer

fcomip st,st(1) ;compare, pop the integer and set CPU flags

jnz contains_decimal

All the FPU data registers are still in the same state as before the above code. Good enough? Just make sure to use the .686 directive to assemble.

Raymond

Hello,

Thank you all very much for your answers.

I was doing approximately the same thing but I wasn't sure it was "the thing to do without errors".

And Raymond, thank you for your tutorials on FPU, they are great !

Regards, Neitsa.

Thank you all very much for your answers.

I was doing approximately the same thing but I wasn't sure it was "the thing to do without errors".

And Raymond, thank you for your tutorials on FPU, they are great !

Regards, Neitsa.

Neitsa

Thanks for the appreciation. Very kind of you.

Raymond

Thanks for the appreciation. Very kind of you.

Raymond

Just to point out the fcomip instruction needs a Pentium Pro CPU minimum.