Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't remember procedure 2

Status
Not open for further replies.

PrograMan

Programmer
Jul 21, 2001
59
0
0
US
I'm dealing with larger numbers here (like, doubles) and I'm trying to take off the decimals (convert to true integers) of a number that's based off the larger number (e.g. 317602 / 3). The number length can get up to 8 places and it's irritating me. What's the procedure to hack off the decimals?
 
that only gives me everything after the decimal. I want everything before the decimal.
 
If you want it rounded off, use n=int(317602 \ 3). If you want the number trunkated, use n=int((317602 \ 3)+.5)


Dan
 
JohnYingling, the \ operator I know is the modolus operator and only returns the remainder of a division problem.

Dan, the int() operation doesn't work. I think I need to somehow convert the double into integer, but the compiler tells me that using Cint() only causes overflow.
 
\ = mod
/ = div

I had long since tested the function of \ operator checking to make sure that wasn't the issue, but it wasn't. I had read up a little on modulus before it anyway.
 
PrograMan

Suggest you re-read the manual and do a little further testing before getting any deeper in!

/ is normal division
\ in integer division (Div)
Mod is Mod

This is cut & pasted from Immediate window to illustrate:
? 20/3
6.66666666666667
? 20\3
6
? 20 mod 3
2

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Well shoot, I had tried that before and I had those other results. I just now tried it again and the results came out better. Thanks guys, it all works out!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top