summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorIsmael Juma <ismael@juma.me.uk>2011-12-03 00:24:13 +0000
committerIsmael Juma <ismael@juma.me.uk>2011-12-03 01:50:08 +0000
commit771f5ca5a11541866b57481ce0068fe8511c320d (patch)
treea1f1f5dfae400ac901b0d7fd21ba0b05320d2063 /test
parent2e14c128e725dfd8eb9ea3568f608c15a1d83658 (diff)
downloadscala-771f5ca5a11541866b57481ce0068fe8511c320d.tar.gz
scala-771f5ca5a11541866b57481ce0068fe8511c320d.tar.bz2
scala-771f5ca5a11541866b57481ce0068fe8511c320d.zip
Delegate to Java's implementation of signum for Long and Int.
The Java implementation is faster as it doesn't have branches. java.lang.Math includes implementations of signum for Double and Float, but I didn't change the ones in scala.math because there is a difference on how negative zero is handled.
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/signum.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/files/jvm/signum.scala b/test/files/jvm/signum.scala
new file mode 100644
index 0000000000..feb28d3e43
--- /dev/null
+++ b/test/files/jvm/signum.scala
@@ -0,0 +1,15 @@
+object Test {
+ def main(args: Array[String]) {
+ assert(math.signum(Long.MaxValue) == 1L)
+ assert(math.signum(1L) == 1L)
+ assert(math.signum(0L) == 0L)
+ assert(math.signum(-1L) == -1L)
+ assert(math.signum(Long.MinValue) == -1L)
+
+ assert(math.signum(Int.MaxValue) == 1)
+ assert(math.signum(1) == 1)
+ assert(math.signum(0) == 0)
+ assert(math.signum(-1) == -1)
+ assert(math.signum(Int.MinValue) == -1)
+ }
+}