|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#14
|
|||||
|
|||||
|
Re: How does division work?
Quote:
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 |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |