Here's a head scratcher for you math fans... - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2) +--- Thread: Here's a head scratcher for you math fans... (/showthread.php?tid=762) |
Here's a head scratcher for you math fans... - Pete - 08-12-2022 So working with repetends and converting them to fractions we have... .333... = 1/3 .666... = 2/3 and now drum roll, please... .999... = 1 Pete RE: Here's a head scratcher for you math fans... - Jack - 08-12-2022 hi Pete I would do something like the following Code: (Select All) Dim As Double x, ip, fp, eps RE: Here's a head scratcher for you math fans... - vince - 08-12-2022 This is such low hanging fruit, like the age-old 0.1+0.2=0.300000000003 or whatever, but I will give a +1 to the first clean, conclusive, & dignified response to this nonsense RE: Here's a head scratcher for you math fans... - Jack - 08-12-2022 are you talking to me vince? I like to see your solution RE: Here's a head scratcher for you math fans... - dcromley - 08-12-2022 (08-12-2022, 02:44 PM)vince Wrote: This is such low hanging fruit, like the age-old 0.1+0.2=0.300000000003 or whatever, but I will give a +1 to the first clean, conclusive, & dignified response to this nonsense I agree (.. nonsense). So many internet bytes have been wasted on .99999.. = 1; reminds me of the excessive threads regarding the Monty Hall "problem". Although the Monty Hall problem is worth the time to get the not-too-difficult "solution", which is not immediately obvious. RE: Here's a head scratcher for you math fans... - Jack - 08-12-2022 all talk and no code, why don't you show us a dignified answer? RE: Here's a head scratcher for you math fans... - SMcNeill - 08-12-2022 Honestly, I don't see why this is a head scratcher at all. @Pete is converting the decimal to a fraction here.. .33... = 1/3 .66... = 2/3 .99... = 3/3 All good and well, and then in the last case his faction just simplifies to 1. I'd imagine the code is written to simplify fractions, at least? Otherwise, why don't we see 0.33 = 2/6 or 100/300, or some such? I suppose it might could give an answer of 1/1, but I imagine there's something in Pete's code that just turns it into an integer, when the divisor is 1, just like it'd probably toss an error with a divisor of 2. Not too much of a head scratcher to think that 3/3 = 1. At least, not to my way of thinking, it's not. RE: Here's a head scratcher for you math fans... - bplus - 08-12-2022 I'm tell'n ya! Decide the decimal precision you desire then round by that. Here is 4 decimals to right of point. Code: (Select All) For i## = 1 To 3 About to be added to b+ GUI BM so that the Slider labels don't start showing this crap: 3.4100000000001 when supposed to be using the int(x * 100)/100 trick that fails on certain numbers 3.41 RE: Here's a head scratcher for you math fans... - Pete - 08-12-2022 Edit: Guys, this post doesn't have anything to do with my algorithm, It works. It's just an observation of a weird special circumstance of mathematics. Point being that in decimal to fraction conversion and back is not reversible in this special instance. .9... = 1 /1 but 1/1 = 1, not .9... So mathematically is .9... = 1? Really? Damn shame when math can't even be perfect. Pete RE: Here's a head scratcher for you math fans... - bplus - 08-12-2022 Math is perfect, discrete math like that done with computers is not. You only know perfect by way of math. |