473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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

May 3 '07 #1
5 1331
On May 3, 11:18 pm, "David Lozzi" <dlo...@nospam.nospamwrote:
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

May 3 '07 #2
Dim i As Integer

i = Math.Floor(30 / 8)

output for i is 3.

On May 3, 4:18 pm, "David Lozzi" <dlo...@nospam.nospamwrote:
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

May 3 '07 #3
Alexey's solution should be more efficient as Math.Floor returns a
double.

On May 3, 5:02 pm, carion1 <ddavi...@gmail.comwrote:
Dim i As Integer

i = Math.Floor(30 / 8)

output for i is 3.

On May 3, 4:18 pm, "David Lozzi" <dlo...@nospam.nospamwrote:
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- Hide quoted text -

- Show quoted text -

May 3 '07 #4
On May 4, 12:05 am, carion1 <ddavi...@gmail.comwrote:
Alexey's solution should be more efficient as Math.Floor returns a
double.

On May 3, 5:02 pm, carion1 <ddavi...@gmail.comwrote:
Dim i As Integer
i = Math.Floor(30 / 8)
output for i is 3.
On May 3, 4:18 pm, "David Lozzi" <dlo...@nospam.nospamwrote:
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- Hide quoted text -
- Show quoted text -- Hide quoted text -

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

May 3 '07 #5
Perfect. Thank you all!!

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
On May 4, 12:05 am, carion1 <ddavi...@gmail.comwrote:
>Alexey's solution should be more efficient as Math.Floor returns a
double.

On May 3, 5:02 pm, carion1 <ddavi...@gmail.comwrote:
Dim i As Integer
i = Math.Floor(30 / 8)
output for i is 3.
On May 3, 4:18 pm, "David Lozzi" <dlo...@nospam.nospamwrote:
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- Hide quoted text -
- Show quoted text -- Hide quoted text -

- 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 "\"
May 4 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Cornelius | last post by:
As an old C programmer, I'm surprised by some results I'm getting with integer division. For example: >>> -1/1000 -1 >>> -9/2 -5 I expect the results of these expressions to be 0 and -4,...
15
by: joel | last post by:
I have a table which I want to update by dividing one field into another. The update runs with no errors, but the results come out as only a positive integer number. The datatype for the result...
9
by: Marcin | last post by:
How I can make division of two numbers placed in arrays, example: short int a = {2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2}; short int b =...
29
by: nessuno | last post by:
I can't find any discussion of this question in this NG. I'd like to implement some variable precision integer arithmetic in C, and do it efficiently. A problem arises with the divide/remainder...
17
by: seb.haase | last post by:
Hi, Is it true that that "Python 3000" is dead ? Honestly I think that e.g. changing 5/2 to be 2.5 (instead of 2) would just break to much code :-( On the otherhand I'm using Python as "Matlab...
10
by: Mike S | last post by:
Does anyone know the logic behind why in VB.NET the result of a floating-point division ('/') is -rounded- on being converted to an integer type, such as with statements like Dim x As Integer =...
2
by: kermit | last post by:
For a long time,, There has been a discussion of trueFor division versus integer division in Python. I myslef prefer that / be used for integer division since almost always, I want the...
13
by: jamesonang | last post by:
Supposed unsigned int(32 bits) is the largest number that computer can represent with a single variable. Now, i have a big integer ( less than 64 bit, but great than 32 bit) . i represent it by...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.