flat assembler
Message board for the users of flat assembler.

 Index > Main > DIV questions.
Author
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?

_________________
27 Dec 2009, 19:39
Fanael

Joined: 03 Jul 2009
Posts: 168
Fanael 27 Dec 2009, 20:03
You mean the remainder? Check EDX.
27 Dec 2009, 20:03
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
27 Dec 2009, 20:21
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.
27 Dec 2009, 20:46
Teehee

Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 27 Dec 2009, 21:06
Oh, nice. Thank you guys.
27 Dec 2009, 21:06
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum