Go to Post So we developed AI... it figured out the clue... already... made itself accordingly... and is currently walking to the peachtree regional if you find him ask him what the objectives are, we'd sure like to know! - Collmandoman [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Spotlight this post!  
Unread 05-01-2008, 00:43
JoeXIII'007's Avatar
JoeXIII'007 JoeXIII'007 is offline
Pragmatic Strategy, I try...
AKA: Joeseph Smith
FRC #0066
Team Role: Alumni
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Ypsilanti, MI (Ann Arbor's shadow)
Posts: 753
JoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond reputeJoeXIII'007 has a reputation beyond repute
Send a message via AIM to JoeXIII'007
Re: How does division work?

Quote:
Originally Posted by JBotAlan View Post
Hey all,

I feel really dumb asking this question, but since I don't have a programming mentor I must rely on what I read, and the community. Since I don't know what to search for ("division" brought up tons of non-related posts...what else should I search for?) I am just going to post this. Sorry if it's a repeat.

If I'm using all integers, how will the RC calculate these:
30/7 = (It rounds to 4, so I assume I'd get 4)
70/6 = (This is where I'm confused...it's 11.6666..., but will the robot round it, or take the floor? Meaning, do I get 12, or 11? I don't have the hardware in front of me to experiment with...)

Thanks for helping with a n00b question...

JBot
Good question... it becomes much of a shocker when you start investigating computer science, you just got to grill it into you head a bit.

type int: The computer will basically divide it as many times evenly into whole number, not part of a whole, and not one more. Since all the computer knows is zeros and ones, at least for type int, it sticks to its whole number interpretation, and fills what it can.

Thus your 70/6 goes to 11... along with 66/6, 67, 68, 69, and 71/6. 72/6 will of course yield 12 though. (Truncation, not rounding... be careful about this difference)

Once you get into type double and float (i think), then the computer believes it can handle decimals, and it will give you decimal answers.


Side note somewhat related: The modulus (%) operator is amazingly useful if you want to find the remainder, for that is what it does. Its even more useful for determining if a given integer is odd or even given you divide by 2 (Example: 66 % 2 gives you 0 since it is even, 65 % 2 gives you 1 since it is odd).

So if I were to run through that above problem again, this time with modulus:

66 % 6 = 0
67........= 1
68........= 2
69........= 3
70........= 4
71........= 5
72........= 0

Have fun... and never be afraid to ask questions after a search goes nowhere.

-Joe
__________________
Joeseph P. Smith
jpthesmithe.com
University of Michigan - Informatics (B. Sci. 2012)
General Purpose Programmer - Cooperative Institute for Limnology and Ecosystems Research (CILER) at NOAA-GLERL
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How does it work? Ryan O Control System 5 12-03-2006 19:15
How does Nationals work? coldfusion1279 Championship Event 29 30-03-2005 16:47
How Does a Winch Work? Aaron Lussier Technical Discussion 23 20-01-2004 21:14
how does crab drive work? Soukup Technical Discussion 13 25-04-2003 11:31
How does Nationals work?? LunchBox Championship Event 16 18-03-2003 15:55


All times are GMT -5. The time now is 23:18.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi