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
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 
Kirk 10389821 wrote:
First, rational numbers would slow things down.
First, in quite a few applications, that doesn't matter. Whether the calculations are done in 10 or 20 milliseconds doesn't matter if you prepare a value that is displayed in an interactive dialog.

Second, if arithmetic calculations is only a small part of the handling, other formats than the traditional floating point may be faster in the other operations. Take an archetypical Cobol application: It reads in, moves around and displays values in counts and dollars and cents; every now and then doing a multiplication, but mostly just addition and subtraction. The time saved in I/O from a BCD format compared to a float format greatly offsets the slower BCD addition/subtraction.

Third: If you use rationals to avoid rounding errors, your float option might be an arbitrary precision float package. Adding 1/3 + 1/6 as rationals is likely to be much faster than calling a library function maintaining a list of mantiass elemnets to add 0.333333.... and 0.16666... for, say, 512 bits.
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 
GeneralHooray Pin
theoldfool9-Jul-18 5:04
professionaltheoldfool9-Jul-18 5:04 
GeneralRe: Hooray Pin
OriginalGriff9-Jul-18 5:11
mveOriginalGriff9-Jul-18 5:11 
GeneralRe: Hooray Pin
DRHuff9-Jul-18 5:27
DRHuff9-Jul-18 5:27 
GeneralRe: Hooray Pin
theoldfool9-Jul-18 5:33
professionaltheoldfool9-Jul-18 5:33 
GeneralRe: Hooray Pin
Bassam Abdul-Baki9-Jul-18 5:51
professionalBassam Abdul-Baki9-Jul-18 5:51 
GeneralRe: Hooray Pin
Mike Hankey9-Jul-18 6:05
mveMike Hankey9-Jul-18 6:05 
GeneralRe: Hooray Pin
DRHuff9-Jul-18 7:31
DRHuff9-Jul-18 7:31 
GeneralRe: Hooray Pin
kmoorevs9-Jul-18 6:38
kmoorevs9-Jul-18 6:38 
GeneralRe: Hooray Pin
Mycroft Holmes9-Jul-18 14:31
professionalMycroft Holmes9-Jul-18 14:31 

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.