help with significant figure function

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Sep 2004
Posts: 13
Reputation: potential is an unknown quantity at this point 
Solved Threads: 0
potential potential is offline Offline
Newbie Poster

help with significant figure function

 
0
  #1
Dec 3rd, 2004
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...
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 11
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: help with significant figure function

 
0
  #2
Dec 4th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 13
Reputation: potential is an unknown quantity at this point 
Solved Threads: 0
potential potential is offline Offline
Newbie Poster

Re: help with significant figure function

 
0
  #3
Dec 6th, 2004
yes. that's what i meant. thanks! i'm super thankful!

:p :cheesy: :p
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 140
Reputation: anastacia is an unknown quantity at this point 
Solved Threads: 1
anastacia's Avatar
anastacia anastacia is offline Offline
Junior Poster

Re: help with significant figure function

 
0
  #4
Dec 6th, 2004
yeah that would definitely work
:lol: I am not one of those who wait for things to happen, :p but one of those who make things happen ;)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC