Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#26 2009-08-13 22:59:01

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 3,847

Re: Sum of fractions which equals 1

bobbym wrote:

Its ctrl + pause/break : this key is above the arrow keys (at the top).

Ah - found it! I'd never used that key before and must have skimmed over it when looking for it. sad

It stops program execution, as you said.

Thanks!


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#27 2009-08-14 13:29:46

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,570

Re: Sum of fractions which equals 1

Hi phrontister;

I tried that, but I got the same incorrect responses as before. Maybe I didn't code it correctly. I'll try again...

for n=10 to 0 step -1/5
   print n
next  n

Notice how instead of getting 0 he gets 0.20539126e-14, but at least the for next loop terminates.

Last edited by bobbym (2009-08-14 13:30:06)


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#28 2009-08-14 13:37:00

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 3,847

Re: Sum of fractions which equals 1

Hi Bobby,

bobbym wrote:

Notice how instead of getting 0 he gets 0.20539126e-14, but at least the for next loop terminates.

Yes - I'll have to remember that for situations where that is important (or maybe I should make it a habit anyway).

Some day this quirk won't exist and we won't have to dream up workarounds...and we'll laugh at the clunky ways of the old days.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#29 2009-08-14 13:49:16

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,570

Re: Sum of fractions which equals 1

Hi phrontister;

This problem will always exist with floating point arithmetic, you can delay it with more digits of precision, but when used incorrectly it will bite you.

Exact integer and rational arithmetic do not have this problem but it is not always possible to use them.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

Board footer

Powered by FluxBB