how to cast a floating point to display an fraction form?? is there a way??
piods
0
Newbie Poster
Recommended Answers
Jump to PostHow do you convert a decimal to fraction on paper?
Jump to PostIs there a way - sure.
You have to code it.
5.xxxx will become 5 (xxxx/10000) then just find the gcd of xxxx & 10000. Divide either with it & you have what you want. 3 ints representing the float.
There could be other ways.
Jump to PostYes, of course.
But are you ready to get a fraction looks like1/(2*1021) - denominator is an integer number with ~308 digits
?
See <float.h> header, DBL_MIN_EXP and DBL_MIN definitions...
All 9 Replies
Colin Mac
53
Posting Whiz
Prabakar
77
Posting Whiz
ArkM
1,090
Postaholic
ArkM
1,090
Postaholic
Prabakar
77
Posting Whiz
ArkM
1,090
Postaholic
ArkM
1,090
Postaholic
ssharish2005
62
Posting Whiz in Training
ArkM
1,090
Postaholic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.