| | |
help with significant figure function
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Sep 2004
Posts: 13
Reputation:
Solved Threads: 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...
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...
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.
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.
![]() |
Similar Threads
- Save function not working (C++)
- Changes the Case of Output Function (C++)
- Call to a Function more than once (Site Layout and Usability)
- Matlab - figure caption (Computer Science)
- Library compatibility problem? (C)
Other Threads in the C Forum
- Previous Thread: Draw sin curve w/ user input, how to code sin()?
- Next Thread: Signed Key
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming spoonfeeding stack standard strchr string strings structures suggestions system systemcall test testautomation unix user voidmain() wab win32api windows.h





:cheesy: :p
