From 771f5ca5a11541866b57481ce0068fe8511c320d Mon Sep 17 00:00:00 2001 From: Ismael Juma Date: Sat, 3 Dec 2011 00:24:13 +0000 Subject: 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. --- test/files/jvm/signum.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/files/jvm/signum.scala (limited to 'test/files') 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) + } +} -- cgit v1.2.3