Function CInt and Int

R

Robert Raley

Access 2000 Windows 2K

I am using a formula that is using INT The results that
are returned do not appear to be correct. The formula is
as follows

Int(180/30.48)=6
Int(178/30.48)=5

When I use the same function in Excel the results are
correct for both which is 5.

Please give some advise as this is holding up our project.

I would also like to know what is CInt aswell and what are
the arithmatic differences between them.

Regards

Bob Raley
 
R

Rick Brandt

Robert Raley said:
Access 2000 Windows 2K

I am using a formula that is using INT The results that
are returned do not appear to be correct. The formula is
as follows

Int(180/30.48)=6
Int(178/30.48)=5

When I use the same function in Excel the results are
correct for both which is 5.

I tried these in both Access 97 and Access 2000. Both gave me 5 as a
return value.

Please give some advise as this is holding up our project.

I would also like to know what is CInt aswell and what are
the arithmatic differences between them.

Int() returns a mathematical integer by truncating the decimal portion of
the number passed to it. It has no size limit.

CInt() converts to a VB integer *type* which also truncates the decimal
portion of the number, but is limited to the range -32,768 to 32,767. If
you pass CInt() a number outside of that range you will get an error.
 
G

Guest

Thank you for the reply. I have tried this again in
another Access data base and always get the same 6.. Do
you have any ideas as to what is happening. I have tried
several test and always get the same answer.

Thanks.

Bob raley
 
R

Rick Brandt

Thank you for the reply. I have tried this again in
another Access data base and always get the same 6.. Do
you have any ideas as to what is happening. I have tried
several test and always get the same answer.

In what context are you using this formula? Have you tried it in the debug
window? Are the operands "hard" numbers or are they the result of previous
calculations? Is it possible they contain more decimal places than what
you see?
 
R

Robert Raley

Dear Rick,

I have tried the formula in the simplest way. Int
(180/30.489) The 180 is a hard number. What I find to be
strange is that I get the correct results with 179. This
thing beats me. Feel like my computer is adding wrong
and I know that is not possible.

Regards
bob
 

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

Top