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

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
 
G

Guest

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
 
G

Guest

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 "\"
 
D

David Lozzi

Perfect. Thank you all!!



Anon User said:
well, it depends what he need to get

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top