flat assembler
Message board for the users of flat assembler.

Index > Main > sse big float value to integer 32bits

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1969
Roman 30 May 2025, 07:05
for example
Code:
;in 32bits program
mov eax,-95000000000.0
movd xmm0,eax
cvtss2si ecx,xmm0 ;I get not int -95000000000. I get -17563648

    

How get correct int value ?
I expected two regs. eax(lower part) and edx(height part)
Post 30 May 2025, 07:05
View user's profile Send private message Reply with quote
Jessé



Joined: 03 May 2025
Posts: 59
Location: Brazil
Jessé 30 May 2025, 08:53
If I understand correctly, there are 2 problems: using single precision for such a big number may corrupt the result; you're trying to fit a conversion result number larger than a 32 bit number into a 32 bit register.
For this, under 32 bit, the best approach might be the FPU:

Code:
; ...
    sub   esp, 8
    finit
    fld    qword [bigfloat]
    fistp  qword [esp]
    pop    eax
    pop    edx

bigfloat    dq -95000000000.0
    
Post 30 May 2025, 08:53
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1969
Roman 31 May 2025, 05:15
Thanks.
I forgot about fpu.
Long time using sse,avx
Post 31 May 2025, 05:15
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.