[RUBY] About getting a tens digit with "(two-digit integer) / 10% 10"

10th place

If the two-digit integer is 29 If it is 29/10, the decimal point will be truncated. In other words, the answer of 29/10 is output as 2 instead of 2.9. Perform 2% 10 as the next calculation. It doesn't break at 10, so the remainder is 2. In other words, the tens place is 2.

100th place

Similarly, if you try to get the number in the 100s, Obtained at 378/100% 10. 378/100=3 3% 10 is 3.

After that 1st place integer / 1% 10 10's place integer / 10% 10 Integer in the hundreds / 100% 10 1000's place integer / 1000% 10 ・ ・ It seems that it can be used.

Is there% 10?

In conclusion, it is not necessary when you want to bring the largest digit. Because it's already a single digit number.

Example

Bring the tens place of 23 →23/10=2 Completed with

Bring the tens place of 123 123/10=12 12%10=2 Completed with

that's all

Recommended Posts

About getting a tens digit with "(two-digit integer) / 10% 10"
Extract each digit number from a 3-digit integer
Getting Started with Java_Chapter 8_About Instances and Classes
Compare Integer with ==
[PHP] A story about outputting PDF with TCPDF + FPDI
A story about trying to get along with Mockito
A story about reducing memory consumption to 1/100 with find_in_batches
A story about developing ROS called rosjava with java
Extract all data about a particular user with ActiveRecord