Post Reply 
New WP34S unit
11-12-2023, 10:46 PM (This post was last modified: 11-12-2023 10:48 PM by Nigel (UK).)
Post: #36
RE: New WP34S unit
That was fun. It turns out that the problem wasn't IGNORE_INVALID_FRACTIONS, nor any error in my code. It's just that the new algorithm converges almost unbelievably slowly, taking more than 3000 iterations to conclude that 0.333333333 is 1/3 (when DENMAX is 9999). This isn't noticeable for the computer versions, and neither is it a problem for the WP34S port on the DM42. But it causes the real calculator to crash - I think that the battery voltage drops and causes a reset. (My batteries aren't new.)

I didn't notice the problem when testing because I was checking the behaviour of numbers like pi and e (for which the algorithm works well) rather than numbers like 1/3 0r 0.01 (for which it doesn't).

So I've abandoned the C47 algorithm and written a new one, using information at this link. The result combines much greater speed with the increased precision of the C47 algorithm. No longer will your calculator tell you that the best approximation to \(\pi\) with DENMAX=100 is \(3\frac17\); instead you'll be correctly told that it is \(3 \frac{14}{99}\). Your calculator won't crash either (I hope).

The code is in the function decNumber2Fraction in decn.c; it's hard to read because it uses decNumbers, but there are comments explaining how it works.

Nigel (UK)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
New WP34S unit - ebs - 10-25-2023, 10:06 PM
RE: New WP34S unit - Paul Dale - 10-26-2023, 04:17 AM
RE: New WP34S unit - Nigel (UK) - 10-27-2023, 01:24 PM
RE: New WP34S unit - ebs - 10-27-2023, 07:29 PM
RE: New WP34S unit - Nigel (UK) - 10-27-2023, 08:38 PM
RE: New WP34S unit - Nigel (UK) - 10-27-2023, 09:10 PM
RE: New WP34S unit - Paul Dale - 10-28-2023, 12:26 AM
RE: New WP34S unit - Nigel (UK) - 10-28-2023, 09:53 AM
RE: New WP34S unit - Paul Dale - 11-03-2023, 11:47 PM
RE: New WP34S unit - ebs - 10-28-2023, 06:03 PM
RE: New WP34S unit - Nigel (UK) - 11-03-2023, 10:30 PM
RE: New WP34S unit - Paul Dale - 11-03-2023, 11:43 PM
RE: New WP34S unit - Nigel (UK) - 11-04-2023, 12:07 AM
RE: New WP34S unit - Paul Dale - 11-04-2023, 03:47 AM
RE: New WP34S unit - ebs - 11-04-2023, 08:22 PM
RE: New WP34S unit - Nigel (UK) - 11-04-2023, 09:44 PM
RE: New WP34S unit - Nigel (UK) - 11-04-2023, 10:02 PM
RE: New WP34S unit - Nigel (UK) - 11-04-2023, 09:52 PM
RE: New WP34S unit - Paul Dale - 11-04-2023, 10:19 PM
RE: New WP34S unit - Nigel (UK) - 11-04-2023, 10:33 PM
RE: New WP34S unit - ebs - 11-05-2023, 07:53 PM
RE: New WP34S unit - Nigel (UK) - 11-05-2023, 08:01 PM
RE: New WP34S unit - ebs - 11-05-2023, 08:36 PM
RE: New WP34S unit - ebs - 11-06-2023, 12:50 AM
RE: New WP34S unit - Nigel (UK) - 11-06-2023, 12:21 PM
RE: New WP34S unit - linq2008 - 11-08-2023, 03:34 AM
RE: New WP34S unit - ebs - 11-06-2023, 11:48 PM
RE: New WP34S unit - ebs - 11-08-2023, 10:45 PM
RE: New WP34S unit - Eric Rechlin - 11-08-2023, 11:39 PM
RE: New WP34S unit - ebs - 11-09-2023, 08:13 AM
RE: New WP34S unit - Nigel (UK) - 11-09-2023, 12:04 PM
RE: New WP34S unit - ebs - 11-09-2023, 12:59 PM
RE: New WP34S unit - Nigel (UK) - 11-11-2023, 06:44 PM
RE: New WP34S unit - ebs - 11-12-2023, 01:50 AM
RE: New WP34S unit - Nigel (UK) - 11-12-2023, 08:22 AM
RE: New WP34S unit - Nigel (UK) - 11-12-2023 10:46 PM
RE: New WP34S unit - Paul Dale - 11-12-2023, 11:47 PM
RE: New WP34S unit - Nigel (UK) - 11-13-2023, 12:11 PM
RE: New WP34S unit - ebs - 11-13-2023, 09:35 PM
RE: New WP34S unit - Nigel (UK) - 11-14-2023, 08:05 PM
RE: New WP34S unit - Paul Dale - 11-14-2023, 12:12 AM
RE: New WP34S unit - Nigel (UK) - 11-14-2023, 08:04 PM
RE: New WP34S unit - burkhard - 11-21-2023, 06:40 PM



User(s) browsing this thread: 1 Guest(s)