I have two decimal numbers. I want those number to be same upto 4 decimal points without rounding. If numbers are different I want 2nd number to be replaced by 1st. What if condition should I write?
Eg,
1.
num1 = 0.94618976
num2 = 0.94620239
If we round these numbers upto 4 decimal then we get 0.9462 same number, but I don't want to round these numbers.
2.
num1 = 0.94620239
num2 = 0.94639125
The one way I found is take absolute difference of both numbers say diff
and then check the value. My problem is of checking the range of diff
.
I am using delphi but you can answer in any language.Thank You.