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...

Recommended Answers

All 3 Replies

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.

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

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

yeah that would definitely work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.