CS people what do you call // ?
-
@futurebird I mean, I'm an engineer, int pi=3
Making it an int is EXTRA offensive. I could forgive float pi=3
-
Making it an int is EXTRA offensive. I could forgive float pi=3
@futurebird but then I can't just divide an int by it and get the result into an int!
-
@futurebird A comment 🏃♂️➡️
@futurebird Darn, I just clicked on reply and didn't see that n people had already said the same thing. Sorry.
-
@futurebird but then I can't just divide an int by it and get the result into an int!
@futurebird I'd have to do // but the text turns grey when I do that!
-
CS people what do you call // ?
As in 16//5=3
* integer divide
* double divide
* floor
* floor divide@futurebird I'd call it an integer divide, I think.
-
Would you say "a div b" if explaining it to a fifth grader?
@futurebird I'd say "division with remainder" if explaining it to a child. "Sixteen divided by five is three remainder one".
But my first computer - a BBC Model B - had DIV and MOD operators
https://www.bbcbasic.co.uk/bbcwin/tutorial/chapter05.html
and I was comfortable using them towards the tail end of primary school.
-
@futurebird I mean, I'm an engineer, int pi=3
@ehproque @futurebird I'm an astronomer. Let's call it ten for now...
-
CS people what do you call // ?
As in 16//5=3
* integer divide
* double divide
* floor
* floor divide@futurebird I have no idea what this even means, but I call it "Slash, slash."
-
@ehproque @futurebird I'm an astronomer. Let's call it ten for now...
-
@ehproque @futurebird I'm an astronomer. Let's call it ten for now...
@khleedril @futurebird I'm a quantum physicist, let's call it 1
-
@futurebird I have no idea what this even means, but I call it "Slash, slash."
You and the whole fifth grade.
-
@khleedril @futurebird I'm a quantum physicist, let's call it 1
@khleedril @futurebird ℏ=h, where is your God now
-
CS people what do you call // ?
As in 16//5=3
* integer divide
* double divide
* floor
* floor divide@futurebird Comment?
*ducks*
-
@futurebird a comment
@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". )
-
@futurebird I used to call it integer division until I learned that at least in Python it doesn't actually return an int.
Now I just call it The Thing That Looks Like It Does What I Need But Better Stay Away From.@martok this operator has returned an int since it was added in Python 2.2, so this seems weird?
-
@futurebird Comment?
*ducks*
@futurebird Jokes aside, is it a floor or a towards-zero like the awful C "division" operator? That would affect proper naming a lot.
-
CS people what do you call // ?
As in 16//5=3
* integer divide
* double divide
* floor
* floor divideI can't read this and not interpret // as a start-of-line-comment marker. So this line is just 16. And I call 16 an integer.
-
@martok this operator has returned an int since it was added in Python 2.2, so this seems weird?
@jhominal Only if both arguments are int. If either is float, the result is float even if its value is by definition int-ish.
I still think this violates the Principle of Least Astonishment, that's why I just don't use it anymore. int(a/b) is not that much more typing.
-
@futurebird nobody knows! There's like a zillion ways to do it because there isn't something like a
"
include <maths>
maths::pi
" -
CS people what do you call // ?
As in 16//5=3
* integer divide
* double divide
* floor
* floor divide@futurebird Years ago I got offered "show your Python skills" quiz on LinkedIn and the answer to this question was given as "integer division". I was so furious I put in a complaint. It is, of course, "floor division". And Python-style modulus is the One True '%' operator –C's remainder can get in the bin.