Click here to Skip to main content
16,005,339 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Dialog problem .. Pin
prasad_som11-Mar-07 6:48
prasad_som11-Mar-07 6:48 
QuestionStupid Algebra Question Pin
Joel Holdsworth10-Mar-07 0:41
Joel Holdsworth10-Mar-07 0:41 
AnswerRe: Stupid Algebra Question Pin
Waldermort10-Mar-07 0:44
Waldermort10-Mar-07 0:44 
GeneralRe: Stupid Algebra Question Pin
Joel Holdsworth10-Mar-07 0:49
Joel Holdsworth10-Mar-07 0:49 
GeneralRe: Stupid Algebra Question Pin
Waldermort10-Mar-07 0:58
Waldermort10-Mar-07 0:58 
GeneralRe: Stupid Algebra Question Pin
toxcct10-Mar-07 2:56
toxcct10-Mar-07 2:56 
AnswerRe: Stupid Algebra Question Pin
Stephen Hewitt10-Mar-07 17:11
Stephen Hewitt10-Mar-07 17:11 
AnswerRe: Stupid Algebra Question Pin
cp987610-Mar-07 17:38
cp987610-Mar-07 17:38 
Joel,

I assume that because you are posting the question here you have to solve this using a representation of y as either a float or double, and this makes it tricky. If you have y, a rational and y=p/q, then as long as it is resuced form, your answer is q. If you represent y as a float or a double, then it is represented in base 2, so if q has any factors other than 2, then the ideal representation is infinite, and so what number is in stored for y as a double, is not exactly equal to y.

This is most easily seen in base 10, any fractions with factors other than 2 or 5 on the denominator, have infinite decimal expansions, and any finite expansion is approximate. So if y = 1/3, y approx = 0.3333333 to 7 places, and with this approximate y the answer to your question is 10000000. The same thing will happen with floats and doubles in programming.

Is there a way around this - well if you know the uncdertainty in the approximation, or if the denominator is less than some maximum value, then you can undo the rounding. The fast way to do this is to use a continued fraction expansion (something to read up on if you don't know of them) they are pretty easy. For example, the continued fraction expansion of 0.3333333 gives as approximations (1/3, 3333332/9999997, 3333333/10000000 - the last one is always exact) and it is pretty easy to pick 1/3 as the likely one. This took about 20 operations.



Questionstring arguments Pin
Kiran Pinjala10-Mar-07 0:05
Kiran Pinjala10-Mar-07 0:05 
AnswerRe: string arguments [modified] Pin
Newbie0010-Mar-07 0:10
Newbie0010-Mar-07 0:10 
GeneralRe: string arguments Pin
Kiran Pinjala10-Mar-07 1:09
Kiran Pinjala10-Mar-07 1:09 
GeneralRe: string arguments Pin
Waldermort10-Mar-07 1:28
Waldermort10-Mar-07 1:28 
GeneralRe: string arguments Pin
Newbie0010-Mar-07 2:30
Newbie0010-Mar-07 2:30 
AnswerRe: string arguments Pin
Mark Salsbery10-Mar-07 7:09
Mark Salsbery10-Mar-07 7:09 
Questionauto run a mfc program Pin
prathuraj9-Mar-07 22:30
prathuraj9-Mar-07 22:30 
AnswerRe: auto run a mfc program [modified] Pin
Eytukan9-Mar-07 23:54
Eytukan9-Mar-07 23:54 
GeneralRe: auto run a mfc program--but what i need is Pin
prathuraj10-Mar-07 0:07
prathuraj10-Mar-07 0:07 
GeneralRe: auto run a mfc program--but what i need is Pin
Waldermort10-Mar-07 0:25
Waldermort10-Mar-07 0:25 
GeneralRe: auto run a mfc program--but what i need is Pin
prathuraj10-Mar-07 0:41
prathuraj10-Mar-07 0:41 
GeneralRe: auto run a mfc program--but what i need is Pin
Waldermort10-Mar-07 0:42
Waldermort10-Mar-07 0:42 
GeneralRe: auto run a mfc program--but what i need is Pin
jeepoo10-Mar-07 2:34
jeepoo10-Mar-07 2:34 
GeneralRe: auto run a mfc program--but what i need is Pin
Waldermort10-Mar-07 3:10
Waldermort10-Mar-07 3:10 
QuestionRe: auto run a mfc program--but what i need is Pin
Rajesh R Subramanian11-Mar-07 3:03
professionalRajesh R Subramanian11-Mar-07 3:03 
QuestionEmail without SMTP Pin
kk.tvm9-Mar-07 21:21
kk.tvm9-Mar-07 21:21 
QuestionRe: Email without SMTP Pin
Hamid_RT11-Mar-07 5:59
Hamid_RT11-Mar-07 5:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.