Last active
August 13, 2016 21:49
-
-
Save metavida/293f5d3a4f127c1ef8ea08a688351a79 to your computer and use it in GitHub Desktop.
Answers to the question: Does (-1%7) resolve to -1 or 6?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node --version | |
v5.6.0 | |
$ node -e "console.log(-1 % 7)" | |
-1 | |
$ bc --version | |
bc 1.06 | |
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. | |
$ echo "-1 % 7 "| bc | |
-1 | |
$ go version | |
go version go1.5 darwin/amd64 | |
$ echo 'package main; import "fmt"; func main() { fmt.Println(-1 % 7) }' > /tmp/glass-test.go | |
$ go run /tmp/glass-test.go | |
-1 | |
$ g++ --version | grep version | |
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 | |
Apple LLVM version 7.0.2 (clang-700.1.81) | |
$ echo -e '#include <iostream>\nint main() { std::cout << -1 % 7 << std::endl; }' > /tmp/glass-test.cpp | |
$ g++ -o /tmp/glass-test.out /tmp/glass-test.cpp | |
$ /tmp/glass-test.out | |
-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby --version | |
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14] | |
$ ruby -e "puts -1 % 7" | |
6 | |
$ python --version | |
Python 2.7.10 | |
$ python -c "print -1 % 7" | |
6 | |
$ perl --version | grep version | |
This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level | |
$ perl -e "print -1 % 7" | |
6 | |
$ crystal --version | |
Crystal 0.18.7 (2016-08-05) | |
$ crystal eval 'puts -1 % 7' | |
6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment