Results 1 to 5 of 5

Thread: Modulus

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Location
    Reykjavík, Iceland
    Posts
    29

    Modulus

    How can you find modulus of a integer number?

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    In VB is Mod
    =========

    A = B Mod 2

    In C++, is %
    =========

    A = B % 2

    A and B are integers.
    I'm a VB6 beginner.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Location
    Reykjavík, Iceland
    Posts
    29
    Yes but how do you do this i assembly?

  4. #4
    Junior Member
    Join Date
    Jun 2000
    Posts
    28
    mov ax, number
    cwd ; sign extend ax into dx:ax
    div word [divisor] ; divide dx:ax by divisor
    ; ax = result
    ; dx = modulus

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    if you need to care for sign extending (i.e. you handle signed integers) you should use IDIV
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width