Problem with writing if condition
Posted
by Himadri
on Stack Overflow
See other posts from Stack Overflow
or by Himadri
Published on 2010-05-14T05:55:34Z
Indexed on
2010/05/14
8:44 UTC
Read the original article
Hit count: 318
if-condition
|delphi
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.
© Stack Overflow or respective owner