I have a situation that I cannot change: one database table (table A) accepts 6 decimal places, while a related column in a different table (table B) only has 3 decimal plac
The basics is to know how to test if there are decimal places, this is done by comparing the value to its rounding
double number;
bool hasDecimals = number == (int) number;
Then, to count 3 decimal places, you just need to do the same for your number multiplied by 1000:
bool hasMoreThan3decimals = number*1000 != (int) (number * 1000)