Dominion Strategy Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 18 19 [20]  All

Author Topic: Random Stuff Part IV  (Read 18283 times)

0 Members and 1 Guest are viewing this topic.

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 7910
  • Respect: +8718
    • View Profile
Re: Random Stuff Part IV
« Reply #475 on: June 24, 2019, 02:41:21 pm »
0

Try calculating sqrt(4)-2 in Windows calculator.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

silverspawn

  • Governor
  • *****
  • Offline Offline
  • Posts: 4189
  • Shuffle iT Username: sty.silver
  • Respect: +1843
    • View Profile
Re: Random Stuff Part IV
« Reply #476 on: June 24, 2019, 02:58:30 pm »
0

Java probably can do that, you're just using the wrong datatype if you need such precision.
well yeah, I didn't expect it to be impossible. But using a non-primitive datatype is way too much effort for this case

Try calculating sqrt(4)-2 in Windows calculator.

-8,1648465955514287168521180122928e-39

I've actually started to use python instead of the windows calculator, since it's about as easy to start and shows me past calculations. And python gives sqrt(4) - 2 = 0.0
Logged

Watno

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2730
  • Shuffle iT Username: Watno
  • Respect: +2948
    • View Profile
Re: Random Stuff Part IV
« Reply #477 on: June 24, 2019, 03:01:19 pm »
0

 I usually use the adress bar of my browser for calculations. I aleady have that open.

Also, are there different Windows calculators? because mine gives me 0.
Logged

silverspawn

  • Governor
  • *****
  • Offline Offline
  • Posts: 4189
  • Shuffle iT Username: sty.silver
  • Respect: +1843
    • View Profile
Re: Random Stuff Part IV
« Reply #478 on: June 24, 2019, 03:01:52 pm »
0



Man, I'd have found it fairly disturbing if e^pi - pi = 20 would actually be true.

I usually use the adress bar of my browser for calculations. I aleady have that open.

I always feel bad about wasting power when I do that.
Logged

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2116
  • Respect: +2642
    • View Profile
Re: Random Stuff Part IV
« Reply #479 on: June 24, 2019, 03:06:04 pm »
+1

Turns out the Windows calculator issue wasn't because of floating point error, it was because the calculator internally represents all numbers as the quotient of really big integers.

http://daviddeley.com/profdeley/math/windows_calculator/index.htm

Newer versions likely did it in a different way. Standard floating point numbers are accurate enough that sqrt(4) just works out to 2.0 which can be represented exactly.
Logged
I have a blog! It's called Sorta Insightful. Check it out?

hhelibebcnofnena

  • Apprentice
  • *****
  • Offline Offline
  • Posts: 290
  • Respect: +166
    • View Profile
Re: Random Stuff Part IV
« Reply #480 on: June 24, 2019, 04:54:22 pm »
0

Man, I'd have found it fairly disturbing if e^pi - pi = 20 would actually be true.

I don't think it would be any more disturbing than e ^ (pi * i) = -1 .
Logged
Hydrogen Helium Lithium Beryllium Boron Carbon Nitrogen Oxygen Fluorine Neon Sodium

silverspawn

  • Governor
  • *****
  • Offline Offline
  • Posts: 4189
  • Shuffle iT Username: sty.silver
  • Respect: +1843
    • View Profile
Re: Random Stuff Part IV
« Reply #481 on: June 24, 2019, 05:05:32 pm »
0

Man, I'd have found it fairly disturbing if e^pi - pi = 20 would actually be true.

I don't think it would be any more disturbing than e ^ (pi * i) = -1 .

It might be hindsight bias, but I think that's a lot less disturbing. These are all very special pieces and the result has norm 1.
Logged

ConMan

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1352
  • Respect: +1612
    • View Profile
Re: Random Stuff Part IV
« Reply #482 on: June 24, 2019, 07:27:02 pm »
0

Ugh, why must precision errors follow me even here? I just had some fun dealing with the fact that the same equation, written in two different languages, operating only on integers, was getting results that differed by 1. I had to implement a clunky version of big integer arithmetic in a language not designed to handle it, to deal with the issue.
Logged

blueblimp

  • Margrave
  • *****
  • Online Online
  • Posts: 2786
  • Respect: +1511
    • View Profile
Re: Random Stuff Part IV
« Reply #483 on: June 25, 2019, 08:23:44 am »
0

Turns out the Windows calculator issue wasn't because of floating point error, it was because the calculator internally represents all numbers as the quotient of really big integers.

http://daviddeley.com/profdeley/math/windows_calculator/index.htm

That's an interesting page, although my takeaway is different: the problem is that the calculator computes square root using multiple operations and the intermediate values can't be exactly represented. The reason they can't be exactly represented is that they're irrational (actually maybe even transcendental), so floating-point should have the same problem if you calculate sqrt that way. I went to try it in Python, and, funnily enough, math.exp(0.5 * math.log(4)) produces exactly 2. I think this is just luck though, because math.exp(0.5 * math.log(9)) does not produce exactly 3. (The "luck" being that the inexactness in the log and exp happen to cancel each other out.)

A more typical sqrt implementation is guaranteed to produce the exact result if it can be represented: https://stackoverflow.com/a/22260439.
Logged

silverspawn

  • Governor
  • *****
  • Offline Offline
  • Posts: 4189
  • Shuffle iT Username: sty.silver
  • Respect: +1843
    • View Profile
Re: Random Stuff Part IV
« Reply #484 on: July 06, 2019, 11:02:04 am »
+3

only in dominion do you buy potions that produce potion that buys alchemists
Logged
Pages: 1 ... 18 19 [20]  All
 

Page created in 0.07 seconds with 20 queries.