CS people what do you call // ?
-
-
-
@futurebird @yonder @ehproque Newton's method converges wonderfully quickly, so it's often a good place to start. I believe that CORDIC algorithms can also do square roots (although I haven't seen or derived one myself) -- those can be nicer for implementation if you don't have an FPU (or are building one), because they tend to be all about adds and bit-shifts and not much else.
CORDIC only generates one digit per iteration, though, whereas Newton doubles the precision each time.
-
um... not really. What do you do? load a math library?
I mean, how much pi do we need? Just type out ten decimal places and make it a global.
@ehproque @futurebird i need more pi
-
Can random.random() be stuck in a constexpr to do that at compile time or did someone rightfully shoot down the idea of compile time nonsererminism?
-
@ehproque @futurebird i need more pi
@burnitdown @futurebird I'm out, but here's some cake

-
Can random.random() be stuck in a constexpr to do that at compile time or did someone rightfully shoot down the idea of compile time nonsererminism?
We don't need any random numbers to be THIS terrible.
inside=0.0
resolution=100
for x in range(resolution):
x=x/resolution
for y in range(resolution):
y=y/resolution
if x*x+y*y<1:
inside+=1pi=4*inside/(resolution*resolution)
print(pi)
-
@futurebird in all seriousnessness, the use of "floor divide" implies the result is rounded towards negative infinity, in contrast with "trunc divide" , which implies rounding toward zero, an important distinction when one operand turns out to be negative. Now here's a question: in your favorite languages, which way does integer divide behave? Does the language definition even require a particular behavior? (C90 and C99 for example call it "implementation defined". )
@llewelly @futurebird floor can also be defined as going toward zero.
Programmers are amazing at not knowing the foundations of things. I worked somewhere that was absolutely confounded by numpy’s use of statistical rounding (x.50 goes to the even value not up, to avoid biasing your data in a systematic manner). I, freshly graduated from college and having taken a stats course, knew what it was immediately.
-
@llewelly @futurebird floor can also be defined as going toward zero.
Programmers are amazing at not knowing the foundations of things. I worked somewhere that was absolutely confounded by numpy’s use of statistical rounding (x.50 goes to the even value not up, to avoid biasing your data in a systematic manner). I, freshly graduated from college and having taken a stats course, knew what it was immediately.
I’m not pointing the “programmers […] not knowing […] things” at you specifically, @llewelly . That’s intended to be a completely separate thought. I’ve got blind spots large enough to park an aircraft carrier in, I’m sure.
@futurebird -
@ehproque @futurebird I'm an astronomer. Let's call it ten for now...
-
We don't need any random numbers to be THIS terrible.
inside=0.0
resolution=100
for x in range(resolution):
x=x/resolution
for y in range(resolution):
y=y/resolution
if x*x+y*y<1:
inside+=1pi=4*inside/(resolution*resolution)
print(pi)
@futurebird you're comparing to 1 so you don't even need root here
-
@futurebird you're comparing to 1 so you don't even need root here
OMG
You know, when I started writing this I had that in mind and just forgot about it... LMAO.
-
@llewelly @futurebird floor can also be defined as going toward zero.
Programmers are amazing at not knowing the foundations of things. I worked somewhere that was absolutely confounded by numpy’s use of statistical rounding (x.50 goes to the even value not up, to avoid biasing your data in a systematic manner). I, freshly graduated from college and having taken a stats course, knew what it was immediately.
@c0dec0dec0de @futurebird imagine you descended to the basement of a strange building, and suddenly found yourself stuck to the ceiling. Such is the world of programming when not everyone agrees on the meaning of floor() ... *sigh*
-
undefined oblomov@sociale.network shared this topic
-
@c0dec0dec0de @futurebird imagine you descended to the basement of a strange building, and suddenly found yourself stuck to the ceiling. Such is the world of programming when not everyone agrees on the meaning of floor() ... *sigh*
@llewelly @c0dec0dec0de @futurebird coming from math, I have to ask: who is doing floor that way?
-
CS people what do you call // ?
As in 16//5=3
* integer divide
* double divide
* floor
* floor divide@futurebird integer divide. Floor divide may or may not be appropriate for negative operands depending on how it is defined.