Click here to Skip to main content
15,912,292 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAdding a tab to the output window in vc6 Pin
Martin Slater28-Mar-03 15:06
Martin Slater28-Mar-03 15:06 
GeneralGet Error__ left of '.point' must have class/struct/union type Pin
wow999928-Mar-03 14:26
wow999928-Mar-03 14:26 
GeneralRe: Get Error__ left of '.point' must have class/struct/union type Pin
John R. Shaw28-Mar-03 15:58
John R. Shaw28-Mar-03 15:58 
GeneralCListBox and HSCROLL Pin
Member 12629228-Mar-03 11:48
Member 12629228-Mar-03 11:48 
GeneralRe: CListBox and HSCROLL Pin
Member 12629228-Mar-03 11:56
Member 12629228-Mar-03 11:56 
Generaldecimal fraction conversion Pin
Aaron Knox28-Mar-03 7:59
Aaron Knox28-Mar-03 7:59 
GeneralRe: decimal fraction conversion Pin
Alvaro Mendez28-Mar-03 8:12
Alvaro Mendez28-Mar-03 8:12 
GeneralRe: decimal fraction conversion Pin
Josh Knox31-Mar-03 7:46
Josh Knox31-Mar-03 7:46 
Hey Dude,

A quick 'n' dirty way of doing it would be to count the number of digits after the decimal point as your numerator and use this number of digits to calculate your denominator.

Ex: .3456 = 3456/10000

That'd give you a fraction at least.

If you want to reduce it, find numbers that divide both the numerator and denominator evenly. Use the modulus operator for this. A result of 0 indicates that the number is evenly divisible.

ex: 2%10=0, evenly divisible
3%10=1, not evenly divisible.

Of course for very long decimals you may want to adopt some fixed amount of places to round off to. You will lose some precision in the number however.

I'd put the whole operation in a function like:

void print_fraction(double decimal_value),

that prints a fraction for the decimal value you pass to it.

Hope this helps.

Josh Knox
GeneralVSS automation Pin
Le centriste28-Mar-03 7:52
Le centriste28-Mar-03 7:52 
GeneralRe: VSS automation Pin
Brian Shifrin29-Mar-03 0:54
Brian Shifrin29-Mar-03 0:54 
GeneralDLL External ref error Pin
Jeff Patterson28-Mar-03 7:20
Jeff Patterson28-Mar-03 7:20 
GeneralRe: DLL External ref error Pin
Le centriste28-Mar-03 7:50
Le centriste28-Mar-03 7:50 
GeneralRe: DLL External ref error Pin
Jeff Patterson28-Mar-03 11:12
Jeff Patterson28-Mar-03 11:12 
GeneralRe: DLL External ref error Pin
John R. Shaw28-Mar-03 16:22
John R. Shaw28-Mar-03 16:22 
Generalcreating DLL in VC++ Pin
Yank128-Mar-03 7:01
Yank128-Mar-03 7:01 
GeneralRe: creating DLL in VC++ Pin
Nemanja Trifunovic28-Mar-03 7:03
Nemanja Trifunovic28-Mar-03 7:03 
QuestionDetermining DLL location? Pin
Justin Cooke28-Mar-03 6:52
Justin Cooke28-Mar-03 6:52 
AnswerRe: Determining DLL location? Pin
Nemanja Trifunovic28-Mar-03 7:02
Nemanja Trifunovic28-Mar-03 7:02 
AnswerRe: Determining DLL location? Pin
Big Art28-Mar-03 7:03
Big Art28-Mar-03 7:03 
AnswerRe: Determining DLL location? Pin
RobJones29-Mar-03 6:54
RobJones29-Mar-03 6:54 
AnswerRe: Determining DLL location? Pin
Justin Cooke31-Mar-03 11:29
Justin Cooke31-Mar-03 11:29 
GeneralSOAP and client certificates Pin
Le centriste28-Mar-03 6:52
Le centriste28-Mar-03 6:52 
GeneralConstructor & Destructor Pin
Makover28-Mar-03 6:08
Makover28-Mar-03 6:08 
GeneralRe: Constructor & Destructor Pin
Chris Losinger28-Mar-03 6:11
professionalChris Losinger28-Mar-03 6:11 
GeneralRe: Constructor & Destructor Pin
Daniel Turini28-Mar-03 6:20
Daniel Turini28-Mar-03 6:20 

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.