FloatToInt purpose is to convert Float to int! :) anyway, there's something strange going on here, which i'm abit confused...

 .data
  a      word     ?
  b      real4    234234124.234234

 .code
  fld    b
  call   FloatToInt
; eax <--- now hold the result

                            +-------- should be 4!
                            |
 and the result is: 234234128 <---- which is incorrect. how come?
 this error occure because 234234124.234234 doesn't fit into real4?
 (try and use the value above and see if you get the correct value).

 but when i have:

 .data
  a      word    ?
  b      real4   34124.234234

 .code
  fld    b
  call   FloatToInt
; eax <--- now hold the result
and the result is: 34124 <--- which is correct. why so? note: i tested it with VC++ and they have the same problem...

  int       a ;
  float     b ;

  b = 234234124.234234;
  a = (int)b; <--- typecast float(b) to int(a)
i execute and debug that code in VC++ and the result is: 234234128 which is also incorrect. :( the last digit should be 4. coud it be: =============================================== 1: there's something wrong with my FloatToInt codec or 2: 234234124.234234 doesn't fit into real4 which one do you think is the cause? 1 or 2? ===============================================
Posted on 2001-07-05 20:23:00 by disease_2000
You are absolutely correct. There are only 24 bits of percission. Try this:

234234124 / 16 = 14639633 (in hex=DF6210)
23-bits are stored in the low bits of a REAL4, and the top bit is assumed to be set! Also note that we rounded up to the next interger. Next step:

14639633 * 16 = 234234128 (look familiar?)
The exponent in a REAL4 is like a shift count to be applied to the number - that's why I used power of two multiply/divide. I have a brighter light here if you still cannot see. ;)
Posted on 2001-07-05 21:54:00 by bitRAKE
thanx for the reply. about the bright light, i think i see it. (why wouldn't a person see a ligh when it's BRIGHT??? silly :D )
Posted on 2001-07-05 22:24:00 by disease_2000
rake, let me see your bright light (i want to see it nonetheless). in your saying, are you refering to the SIGN bit??? give me your brigh light so i can make it even brighter!!
Posted on 2001-07-05 22:34:00 by disease_2000
I'm very silly after a boring day at work. :) You could have found such an elementary answer as bright as you are? Don't you have documentation where you are at? Intel Architecture Software Developer's Manual Volume 1:Basic Architecture Section 7.4.1, combined with a little binary knowledge?
Posted on 2001-07-05 22:39:00 by bitRAKE
Okay, the (exponent - 127) is the shift count from the imaginary decimal point - which sits behind the imaginary set bit. :) The sign is nothing special. :)

1:8:23 = sign:exponent(shift+127):fraction
fraction always has an imaginary set bit in front. If the exponent & fraction are zero then the number is zero. I'm not so bright, I have the manual here. :D
Posted on 2001-07-05 22:53:00 by bitRAKE
rake, my understanding of english isn't perfect(so is my grammar). when you explain things to me, you have to keep it simple or else i'll hunt you with more question.

"that's why I used power of two multiply/divide."
to me, that's like French you're speaking in. :) so i ask you you to show me the light, so that i can make sure i'm on the same boat as you. in reality, fraction (i wouldn't say that. i would called rakesion :D ) are always thought (or imaginary as you stated). I believe i've read chapter 1 of the Art of assembly 5 time! so no need for me to explain it here. chapter 1 talks alot about binary (believe me, once you read it more than once, you will memorize for LIFE!). so, your answer above varify me that we're on the same boat (boy, i'm scare.. vecna might attack us. he has a mask on...). This message was edited by disease_2000, on 7/5/2001 11:32:18 PM
Posted on 2001-07-05 23:24:00 by disease_2000
You are too funny! :D I knew I should have taken French in high school - never have used the Spanish. :) I'll try to keep it simple, but I am a complex American (my doctor keeps using the word 'pathology' when he tells them about my condition :)) Your English is very good. Try: Section 7.4.1 The more explainations the better, and the pictures aren't too bad either. (I like pictures) I think you can order these in French? (33) (1) 45717171 is their phone number - give 'em a call? :) Maybe, I should have said, "I'm not so bright, I have the manuals here in my native tonge." I've had enough water for tonight, thank you - come to think of it - I've fell off the end of boat...
Posted on 2001-07-06 00:04:00 by bitRAKE