flat assembler
Message board for the users of flat assembler.

Index > Main > DIV questions.

Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 27 Dec 2009, 19:39
152 / 100 = 1.52

Code:
mov eax, 152
mov ebx, 100
cdq
div ebx
; eax = 1    

To where .52 goes?

_________________
Sorry if bad english.
Post 27 Dec 2009, 19:39
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 27 Dec 2009, 20:03
You mean the remainder? Check EDX.
Post 27 Dec 2009, 20:03
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 27 Dec 2009, 20:21
No, he means the fractional part. Integer maths don't have fractional parts, they just get truncated towards 0.

You would need to use the FPU to have a fractional part, or you could use fixed-point maths.

_________________
----> * <---- My star, won HERE
Post 27 Dec 2009, 20:21
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 27 Dec 2009, 20:46
In decimal: Multiply numerator by 100, the numbers <100 can be considered fractional.

In binary: Multiply by a power of 2, the respective bits can be used as fractional bits.
Post 27 Dec 2009, 20:46
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 27 Dec 2009, 21:06
Oh, nice. Thank you guys.
Post 27 Dec 2009, 21:06
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.