Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Perpetual string math calculator.
#11
Since this is string math, I think you guys are overlooking one obvious thing.

Let's take 1/3 for an example -- the answer is "0.33..."

See that "..." at the end there? That tells you that you're dealing with a repeating fraction, Without it, you're just dealing with 0.33. You don't need to go looking for a repeating pattern; just make certain to assign those "..." to the end of your results, and then if you need to reverse engineer the answer, you can easily do so without having to look for a repeating pattern which may or may not be there. "0.33" could be 1/3 rounded to 2 digits, or it could just be 33/100.

Since you're not just doing numeric-math, but are instead doing full fledged string-manipulation, why not give meaningful results with your string answer which holds more information than just numbers can provide?

I'd suggest a simple "...##" approach, where "..." represents something repeating, and "##" represents how many digits before the repetition. With such a method, 1/3 is "0.3...1" -- with one glance you can tell that you have one repeating digit, and it's the 3. From there you can do your reverse magic mumbo jumbo if you need to, to turn it back into 1/3, and then you can process it from there.

1/3 = 0..3...1
0.3...1 * 0.3...1 = (1/3) * (1/3) = (1/9)
Reply


Messages In This Thread
Perpetual string math calculator. - by Pete - 08-10-2022, 05:11 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 03:24 AM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 12:39 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 08:29 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 10:08 PM
RE: Perpetual string math calculator. - by bplus - 08-11-2022, 10:07 PM
RE: Perpetual string math calculator. - by Jack - 08-11-2022, 10:35 PM
RE: Perpetual string math calculator. - by SMcNeill - 08-11-2022, 11:03 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 11:35 PM
RE: Perpetual string math calculator. - by Jack - 08-11-2022, 11:42 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 11:51 PM
RE: Perpetual string math calculator. - by Pete - 08-12-2022, 01:56 AM



Users browsing this thread: 7 Guest(s)