Search Members Help

» Welcome Guest
[ Log In :: Register ]

 

[ Track This Topic :: Email This Topic :: Print this topic ]

reply to topic new topic new poll
Topic: c++ data types< Next Oldest | Next Newest >
 Post Number: 1
a.out Search for posts by this member.
FNG
Avatar



Group: Members
Posts: 58
Joined: Jan. 2001
PostIcon Posted on: Sep. 26 2001,23:43  Skip to the next post in this topic. Ignore posts   QUOTE

I have to write a program for my c++ course, and one of the requirements is to allow the user to enter a number of feet, and the program should output the WHOLE number of miles in that number of feet, and then the number of miles left over. This is very simply to do, simply doing integer division, and then doing a feet\%5280 (modulus) operation to get the remainder. However, my instructor decided to add a requirement that the number that can be entered by the user can be as long as 13-14 digits. So, what type of variable do I use?
It needs to be integral to use the \% operator, so no floats or doubles. I did mess around some, and I found that a "double long" was a valid type, which was basically twice as long as a "long" (4 bytes on the school's systems, so the double long was 8 bytes). However, this data type doesn't seem to work with the modulus operator. I am at a loss of what type to use. Any suggestions?

Edit: BTW, we are using Codewarrior 4 or something on WinNT

This message has been edited by a.out on September 27, 2001 at 06:44 PM

Offline
Top of Page Profile Contact Info WEB 
 Post Number: 2
@$$h0l3 Search for posts by this member.
FNG
Avatar



Group: Members
Posts: 40
Joined: Dec. 2000
PostIcon Posted on: Sep. 27 2001,00:44 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

Well, if the integer math works (i.e. miles = input / 5280), miles will return a whole number. Just do feet = input - miles * 5280.
Offline
Top of Page Profile Contact Info 
 Post Number: 3
a.out Search for posts by this member.
FNG
Avatar



Group: Members
Posts: 58
Joined: Jan. 2001
PostIcon Posted on: Sep. 30 2001,04:47 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

I finally found a variable type that works with this. It's strange, because I hadn't ever heard of it before, and neither had my instructor. It's "unsigned long long". Weird. But it worked...
Offline
Top of Page Profile Contact Info WEB 
 Post Number: 4
damien_s_lucifer Search for posts by this member.
Emperor of Detnet
Avatar



Group: Members
Posts: 33
Joined: Jan. 1970
PostIcon Posted on: Oct. 02 2001,16:31 Skip to the previous post in this topic.  Ignore posts   QUOTE

"long long" has been a valid data type for a while now. It's generally an integer that uses 64 bits instead of 32.

Offline
Top of Page Profile Contact Info WEB 
3 replies since Sep. 26 2001,23:43 < Next Oldest | Next Newest >

[ Track This Topic :: Email This Topic :: Print this topic ]


 
reply to topic new topic new poll

» Quick Reply c++ data types
iB Code Buttons
You are posting as:

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code