Click here to Skip to main content
15,922,894 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
swampwiz9-Jul-18 13:40
swampwiz9-Jul-18 13:40 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
kalberts10-Jul-18 3:37
kalberts10-Jul-18 3:37 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
CPallini9-Jul-18 21:15
mveCPallini9-Jul-18 21:15 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
obermd10-Jul-18 5:28
obermd10-Jul-18 5:28 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
megaadam9-Jul-18 5:14
professionalmegaadam9-Jul-18 5:14 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
GuyThiebaut9-Jul-18 6:44
professionalGuyThiebaut9-Jul-18 6:44 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
kalberts9-Jul-18 11:40
kalberts9-Jul-18 11:40 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
harold aptroot9-Jul-18 7:52
harold aptroot9-Jul-18 7:52 
You may also consider a continued fraction representation which can also be calculated with, and if you allow them to be "generators" they can even represent some annoying numbers such as e and phi and irrational square roots.
But this also has various problems. For example, when subtracting "accidentally equal" numbers (ie two generators that are not the same instance and not binary equivalent, but generate the same list) it takes infinite steps to find out that there is never a difference, and this delays the generation of the "head" of the result generator infinitely long (ie there is no answer).
Working with finite CFs necessarily means that some numbers cannot be represented any more since they get truncated at some point.

By the way, floating point arithmetic is more exact than many people give it credit for. It doesn't always have to round, for example subtracting two numbers with equal sign that are within a factor of 2 of each other results in the actual difference between the two numbers (Sterbenz lemma). A large part of that perception is the great Decimal Bias of the modern world (at other times in history it would have been a Sexagesimal Bias), but there is nothing inherent about a base ten system.
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
PIEBALDconsult9-Jul-18 8:22
mvePIEBALDconsult9-Jul-18 8:22 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
kalberts9-Jul-18 11:41
kalberts9-Jul-18 11:41 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
Super Lloyd9-Jul-18 14:10
Super Lloyd9-Jul-18 14:10 
AnswerRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
John Stewien10-Jul-18 0:03
John Stewien10-Jul-18 0:03 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
gdemont10-Jul-18 2:20
gdemont10-Jul-18 2:20 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
kalberts10-Jul-18 4:12
kalberts10-Jul-18 4:12 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
swampwiz10-Jul-18 4:47
swampwiz10-Jul-18 4:47 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
Kirk 1038982110-Jul-18 3:50
Kirk 1038982110-Jul-18 3:50 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
kalberts10-Jul-18 4:24
kalberts10-Jul-18 4:24 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
englebart10-Jul-18 4:03
professionalenglebart10-Jul-18 4:03 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
Bruce Patin10-Jul-18 4:16
Bruce Patin10-Jul-18 4:16 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
Daniel Wilianto10-Jul-18 16:40
Daniel Wilianto10-Jul-18 16:40 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
kalberts11-Jul-18 9:05
kalberts11-Jul-18 9:05 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
Vivi Chellappa11-Jul-18 14:00
professionalVivi Chellappa11-Jul-18 14:00 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
kalberts12-Jul-18 1:59
kalberts12-Jul-18 1:59 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
Vivi Chellappa12-Jul-18 23:54
professionalVivi Chellappa12-Jul-18 23:54 
GeneralRe: How hard would it be to have a Rational Number type, so that there would never be floating point errors? Pin
bjongejan18-Jul-18 0:18
bjongejan18-Jul-18 0:18 

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.