0
How to divide two numbers without using arithmetic expression.
4 odpowiedzi
+ 4
Division is basically...how many times THIS thing fits into THAT thing.
To get at the idea, if I were using a physical measuring ruler and piece of paper:
[ ruler ]
[ paper ]
I'd run my pencil to the end of the paper, make a mark on the ruler, then set the paper down again on the other side and repeat (looks like we can at least divide by 2).
[ ruler x x ]
.............^[ paper ]
The ruler has a certain length, so does the paper, and languages like Java can loop from start -> finish of something with length.
I suspect Java also has objects with a length attribute (and methods) that you can use to count (and query the count) without using arithmetic.
- 1
If the second is a power of 2, use bit shift.
- 1
Code plz