Hi! I got a decimal number, 28.1*4* . I want to mane a method that returns the last decimal digit, in this case, 4! how can I do so?
Multiply by 100 and take the modulus 10?
Oh, this is SO embarrassing! I should have known that! Thanks! :)
be aware that float math can always give rounding errors, so 100 x 28.14 might become 2813(.9999)
You can round it to the nearest integer by adding 0.5 to the float value before the conversion to an integer.