943,970 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 2784
  • C RSS
Dec 3rd, 2004
0

help with significant figure function

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
potential is offline Offline
13 posts
since Sep 2004
Dec 4th, 2004
0

Re: help with significant figure function

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.
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 2004
Dec 6th, 2004
0

Re: help with significant figure function

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

:p :cheesy: :p
Reputation Points: 10
Solved Threads: 0
Newbie Poster
potential is offline Offline
13 posts
since Sep 2004
Dec 6th, 2004
0

Re: help with significant figure function

yeah that would definitely work
Reputation Points: 11
Solved Threads: 1
Junior Poster
anastacia is offline Offline
142 posts
since Nov 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Draw sin curve w/ user input, how to code sin()?
Next Thread in C Forum Timeline: Signed Key





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC