0

guys, i need your help. please...

i need to make a function which compares 2 values if they are equal up to 1,2,3,4,5 significant figures.

it needs 3 parameters: x1, x2 (the values to be compared) and sf (the # of sign. figures)

i think i need to subtract x1 and x2 and divide it with a number...

please help me... please give me tips or something...i really really tried, but i still can't successfully figure out what to do...

3
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by anastacia
0

you mean like:

1.2345
1.2344

is the same to 3 figures?

So, couldn't you say

int intX1 = (int)(x1 * figures);
int intX2 = (int)(x2 * figures);

if (intX1 == intX2) <same>

where figures is 10 for 1 place, 100 for 2 places, 1000 for three and so on?

This would work to about 9 total digits, but similar methods could give you more.

0

yes. that's what i meant. thanks! i'm super thankful!

:p :D ;) :cheesy: :p :cool:

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.