Novice question by a pro.... division and remainders

  • Thread starter Thread starter David Lozzi
  • Start date Start date
D

David Lozzi

Howdy,

I feel quite embarrased asking this question, but for the life of me i can't
figure this out. I haven't run a debug, but I think what is happening is
that i'm doing some division and its rounding up when necessary, for
example.

Dim i as integer
Dim r as integer
i = 30 / 8
r = 30 mod 8

from what I can see in the way my code is responding, i is equal to 4, not
3. The mod works correctly, returns 6. How do i get this stupid thing to
work?

Thanks!
David Lozzi
 
Howdy,

I feel quite embarrased asking this question, but for the life of me i can't
figure this out. I haven't run a debug, but I think what is happening is
that i'm doing some division and its rounding up when necessary, for
example.

Dim i as integer
Dim r as integer
i = 30 / 8
r = 30 mod 8

from what I can see in the way my code is responding, i is equal to 4, not
3. The mod works correctly, returns 6. How do i get this stupid thing to
work?

Thanks!
David Lozzi

30 \ 8
 
Alexey's solution should be more efficient as Math.Floor returns a
double.







- Show quoted text -

well, it depends what he need to get

i = Int(30 / 8) will do the same result (3) as an integer division
operator "\"
 
Perfect. Thank you all!!



Alexey Smirnov said:
well, it depends what he need to get

i = Int(30 / 8) will do the same result (3) as an integer division
operator "\"
 
Back
Top