Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,327 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,093 people online right now. Registration is fast and FREE... Join Now!




Float or Custom?

 
Reply to this topicStart new topic

Float or Custom?

Kakashi24142
post 15 Mar, 2008 - 12:20 PM
Post #1


New D.I.C Head

*
Joined: 14 Mar, 2008
Posts: 8

Ok, this is more of a suggestion of what to do based on my current situation. My situation is that I'm planning on creating a simple calculator and I want 100% accurate calculations. But I discovered that floats only allow 6 digits that makes everything worse when dealing with big rational numbers. SO to deal with this should I create a class that handles rational numbers totally or I continue to use float?
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 15 Mar, 2008 - 12:35 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,027



Thanked 173 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Well the double type is your next data type to try (typically it is around 53 bit mantissa or 15 digits). If that is still too small for your numbers, then yes you will have to go with a custom made class. You can find some already made classes for handling big numbers on the web. Simply do a search.

I hope that answers your question. smile.gif
User is offlineProfile CardPM

Go to the top of the page

Kakashi24142
post 15 Mar, 2008 - 12:54 PM
Post #3


New D.I.C Head

*
Joined: 14 Mar, 2008
Posts: 8

Yes it helps thanks.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 02:45AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month