dbl -> toDouble

This commit is contained in:
Alex Tkachman
2012-02-22 13:14:41 +02:00
parent 18990e2c1b
commit 53bba59a4f
79 changed files with 335 additions and 298 deletions
@@ -1,5 +1,5 @@
fun StringBuilder.takeFirst(): Char {
if (this.length() == 0) return 0.char
if (this.length() == 0) return 0.toChar()
val c = this.charAt(0)
this.deleteCharAt(0)
return c
@@ -8,7 +8,7 @@ fun StringBuilder.takeFirst(): Char {
fun foo(expr: StringBuilder): Int {
val c = expr.takeFirst()
when(c) {
0.char -> throw Exception("zero")
0.toChar() -> throw Exception("zero")
else -> throw Exception("nonzero" + c)
}
}
+12 -12
View File
@@ -62,43 +62,43 @@ fun t3() : Boolean {
}
fun t4() : Boolean {
var x = 100.float
var x = 100.toFloat()
val y = x + 22
val foo = {
x = x + 200.float + y
x = x + 200.toFloat() + y
x += 18
#()
}
foo()
System.out?.println(x)
return x == 440.float
return x == 440.toFloat()
}
fun t5() : Boolean {
var x = 100.double
var x = 100.toDouble()
val y = x + 22
val foo = {
x = x + 200.double + y
x = x + 200.toDouble() + y
x -= 22
#()
}
foo()
System.out?.println(x)
return x == 400.double
return x == 400.toDouble()
}
fun t6() : Boolean {
var x = 20.byte
var x = 20.toByte()
val y = x + 22
val foo = {
x = (x + 20.byte + y).byte
x = (x + 20.toByte() + y).toByte()
x += 2
x--
#()
}
foo()
System.out?.println(x)
return x == 83.byte
return x == 83.toByte()
}
fun t7() : Boolean {
@@ -113,17 +113,17 @@ fun t7() : Boolean {
}
fun t8() : Boolean {
var x = 20.short
var x = 20.toShort()
val foo = {
val bar = {
x = 30.short
x = 30.toShort()
#()
}
bar()
#()
}
foo()
return x == 30.short
return x == 30.toShort()
}
fun t9(var x: Int) : Boolean {
+10 -10
View File
@@ -3,24 +3,24 @@ class A() {
var xin : Int? = 0
var xinn : Int? = null
var xl = 0.long
var xln : Long? = 0.long
var xl = 0.toLong()
var xln : Long? = 0.toLong()
var xlnn : Long? = null
var xb = 0.byte
var xbn : Byte? = 0.byte
var xb = 0.toByte()
var xbn : Byte? = 0.toByte()
var xbnn : Byte? = null
var xf = 0.float
var xfn : Float? = 0.float
var xf = 0.toFloat()
var xfn : Float? = 0.toFloat()
var xfnn : Float? = null
var xd = 0.double
var xdn : Double? = 0.double
var xd = 0.toDouble()
var xdn : Double? = 0.toDouble()
var xdnn : Double? = null
var xs = 0.short
var xsn : Short? = 0.short
var xs = 0.toShort()
var xsn : Short? = 0.toShort()
var xsnn : Short? = null
}
@@ -27,7 +27,7 @@ class Luhny() {
// Commented for KT-621
// when (it) {
// .isDigit() => digits.addLast(it.int - '0'.int)
// .isDigit() => digits.addLast(it.toInt() - '0'.toInt())
// ' ', '-' => {}
// else => {
// printAll()
@@ -36,7 +36,7 @@ class Luhny() {
// }
if (it.isDigit()) {
digits.addLast(it.int - '0'.int)
digits.addLast(it.toInt() - '0'.toInt())
} else if (it == ' ' || it == '-') {
} else {
printAll()
@@ -123,6 +123,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
body(i.char)
body(i.toChar())
} while(true)
}
@@ -25,13 +25,13 @@ class Luhny() {
// Commented for KT-621
// when (it) {
// .isDigit() => digits.addLast(it.int - '0'.int)
// .isDigit() => digits.addLast(it.toInt() - '0'.toInt())
// ' ', '-' => {}
// else => printAll()
// }
if (it.isDigit()) {
digits.addLast(it.int - '0'.int)
digits.addLast(it.toInt() - '0'.toInt())
} else if (it == ' ' || it == '-') {
} else {
printAll()
@@ -102,6 +102,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
body(i.char)
body(i.toChar())
} while(true)
}
@@ -26,7 +26,7 @@ class Luhny() {
// Commented for KT-621
// when (it) {
// .isDigit() => digits.push(it.int - '0'.int)
// .isDigit() => digits.push(it.toInt() - '0'.toInt())
// ' ', '-' => {}
// else => {
// printAll()
@@ -35,7 +35,7 @@ class Luhny() {
// }
if (it.isDigit()) {
digits.push(it.int - '0'.int)
digits.push(it.toInt() - '0'.toInt())
} else if (it == ' ' || it == '-') {
} else {
printAll()
@@ -139,6 +139,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
body(i.char)
body(i.toChar())
} while(true)
}
@@ -2,9 +2,9 @@ package name
class Test() {
var i = 5
val ten = 10.long
val ten = 10.toLong()
fun Long.t() = this.int + i++ + ++i
fun Long.t() = this.toInt() + i++ + ++i
fun tt() = ten.t()
}
@@ -5,5 +5,5 @@ fun Long?.inv() : Long = this.sure().inv()
fun box() : String {
val x : Long? = 10
System.out?.println(x.inv())
return if(x.inv() == -11.long) "OK" else "fail"
return if(x.inv() == -11.toLong()) "OK" else "fail"
}
@@ -1,11 +1,11 @@
fun box() : String {
System.out?.println(System.out?.println(10.float..11.float))
System.out?.println(System.out?.println(10.toFloat()..11.toFloat()))
for(f in 10.float..11.float step 0.3.float) {
for(f in 10.toFloat()..11.toFloat() step 0.3.toFloat()) {
System.out?.println(f)
}
for(f in 10.double..11.double step 0.3.double) {
for(f in 10.toDouble()..11.toDouble() step 0.3.toDouble()) {
System.out?.println(f)
}
@@ -9,22 +9,22 @@ fun box() : String {
if(r4.end != 5 || r4.isReversed || r4.size != 6) return "fail"
val r5 = ByteRange(1, 4)
if(r5.end != 4.byte || r5.isReversed || r5.size != 4) return "fail"
if(r5.end != 4.toByte() || r5.isReversed || r5.size != 4) return "fail"
val r7 = -(0.byte..5.byte)
if(r7.start != 5.byte || r7.end != 0.byte || !r7.isReversed) return "fail"
val r7 = -(0.toByte()..5.toByte())
if(r7.start != 5.toByte() || r7.end != 0.toByte() || !r7.isReversed) return "fail"
val r9 = -r7
if(r9.end != 5.byte || r9.isReversed) return "fail"
if(r9.end != 5.toByte() || r9.isReversed) return "fail"
val r10 = ShortRange(1, 4)
if(r10.end != 4.short || r10.isReversed || r10.size != 4) return "fail"
if(r10.end != 4.toShort() || r10.isReversed || r10.size != 4) return "fail"
val r12 = -(0.short..5.short)
if(r12.start != 5.short || r12.end != 0.short || !r12.isReversed) return "fail"
val r12 = -(0.toShort()..5.toShort())
if(r12.start != 5.toShort() || r12.end != 0.toShort() || !r12.isReversed) return "fail"
val r13 = -r12
if(r13.end != 5.short || r13.isReversed) return "fail"
if(r13.end != 5.toShort() || r13.isReversed) return "fail"
val r14 = CharRange('a', 4)
if(r14.end != 'd' || r14.isReversed || r14.size != 4) return "fail"
@@ -1,11 +1,11 @@
fun box() : String {
val fps : Double = 1.double
val fps : Double = 1.toDouble()
var mspf : Long
{
if ((fps.int == 0))
if ((fps.toInt() == 0))
mspf = 0
else
mspf = (((1000.0 / fps)).long)
mspf = (((1000.0 / fps)).toLong())
}
return "OK"
}
@@ -1,5 +1,5 @@
val _0 : Double = 0.0
val _0dbl : Double = 0.double
val _0dbl : Double = 0.toDouble()
fun box() : String {
if(_0 != _0dbl) return "fail"
@@ -8,7 +8,7 @@ public open class PerfectNumberFinder() {
var factors : List<Int?>? = ArrayList<Int?>()
factors?.add(1)
factors?.add(number)
for (i in 2..(Math.sqrt((number).double) - 1).int)
for (i in 2..(Math.sqrt((number).toDouble()) - 1).toInt())
if (((number % i) == 0)) {
factors?.add(i)
if (((number / i) != i))
@@ -8,7 +8,7 @@ fun test1() : Boolean {
}
fun test2() : Boolean {
val r1 = 1.byte..10.byte
val r1 = 1.toByte()..10.toByte()
var s1 = 0
for(e in r1 step 2) {
s1 += e
@@ -17,21 +17,21 @@ fun test2() : Boolean {
}
fun test3() : Boolean {
val r1 = 1.byte..10.long
var s1 = 0.long
val r1 = 1.toByte()..10.toLong()
var s1 = 0.toLong()
for(e in r1 step 2) {
s1 += e
}
return s1 == 25.long
return s1 == 25.toLong()
}
fun test4() : Boolean {
val r1 = 1.byte..10.short
var s1 = 0.short
val r1 = 1.toByte()..10.toShort()
var s1 = 0.toShort()
for(e in r1 step 2) {
s1 += e
}
return s1 == 25.short
return s1 == 25.toShort()
}
fun test5() : Boolean {
+26 -26
View File
@@ -15,51 +15,51 @@ fun testInt () : String {
}
fun testByte () : String {
val r1 = 1.byte upto 4.byte
if(r1.end != 4.byte || r1.isReversed || r1.size != 4) return "byte upto fail"
val r1 = 1.toByte() upto 4.toByte()
if(r1.end != 4.toByte() || r1.isReversed || r1.size != 4) return "byte upto fail"
val r2 = 4.byte upto 1.byte
if(r2.start != 0.byte || r2.size != 0) return "byte negative upto fail"
val r2 = 4.toByte() upto 1.toByte()
if(r2.start != 0.toByte() || r2.size != 0) return "byte negative upto fail"
val r3 = 5.byte downto 0.byte
if(r3.start != 5.byte || r3.end != 0.byte || !r3.isReversed || r3.size != 6) return "byte downto fail"
val r3 = 5.toByte() downto 0.toByte()
if(r3.start != 5.toByte() || r3.end != 0.toByte() || !r3.isReversed || r3.size != 6) return "byte downto fail"
val r4 = 5.byte downto 6.byte
if(r4.start != 0.byte || r4.end != 0.byte || !r3.isReversed || r4.size != 0) return "byte negative downto fail"
val r4 = 5.toByte() downto 6.toByte()
if(r4.start != 0.toByte() || r4.end != 0.toByte() || !r3.isReversed || r4.size != 0) return "byte negative downto fail"
return "OK"
}
fun testShort () : String {
val r1 = 1.short upto 4.short
if(r1.end != 4.short || r1.isReversed || r1.size != 4) return "short upto fail"
val r1 = 1.toShort() upto 4.toShort()
if(r1.end != 4.toShort() || r1.isReversed || r1.size != 4) return "short upto fail"
val r2 = 4.short upto 1.short
if(r2.start != 0.short || r2.size != 0) return "short negative upto fail"
val r2 = 4.toShort() upto 1.toShort()
if(r2.start != 0.toShort() || r2.size != 0) return "short negative upto fail"
val r3 = 5.short downto 0.short
if(r3.start != 5.short || r3.end != 0.short || !r3.isReversed || r3.size != 6) return "short downto fail"
val r3 = 5.toShort() downto 0.toShort()
if(r3.start != 5.toShort() || r3.end != 0.toShort() || !r3.isReversed || r3.size != 6) return "short downto fail"
val r4 = 5.short downto 6.short
if(r4.start != 0.short || r4.end != 0.short || !r3.isReversed || r4.size != 0) return "short negative downto fail"
val r4 = 5.toShort() downto 6.toShort()
if(r4.start != 0.toShort() || r4.end != 0.toShort() || !r3.isReversed || r4.size != 0) return "short negative downto fail"
return "OK"
}
fun testLong () : String {
val r1 = 1.long upto 4.long
if(r1.end != 4.long || r1.isReversed || r1.size != 4.long) return "long upto fail"
val r1 = 1.toLong() upto 4.toLong()
if(r1.end != 4.toLong() || r1.isReversed || r1.size != 4.toLong()) return "long upto fail"
val r2 = 4.long upto 1.long
if(r2.start != 0.long || r2.size != 0.long) return "short negative long fail"
val r2 = 4.toLong() upto 1.toLong()
if(r2.start != 0.toLong() || r2.size != 0.toLong()) return "short negative long fail"
val r3 = 5.long downto 0.long
if(r3.start != 5.long || r3.end != 0.long || !r3.isReversed || r3.size != 6.long) return "long downto fail"
val r3 = 5.toLong() downto 0.toLong()
if(r3.start != 5.toLong() || r3.end != 0.toLong() || !r3.isReversed || r3.size != 6.toLong()) return "long downto fail"
val r4 = 5.long downto 6.long
if(r4.start != 0.long || r4.end != 0.long || !r3.isReversed || r4.size != 0.long) return "long negative downto fail"
val r4 = 5.toLong() downto 6.toLong()
if(r4.start != 0.toLong() || r4.end != 0.toLong() || !r3.isReversed || r4.size != 0.toLong()) return "long negative downto fail"
return "OK"
}
@@ -70,13 +70,13 @@ fun testChar () : String {
if(r1.end != 'd' || r1.isReversed || r1.size != 4) return "char upto fail"
val r2 = 'd' upto 'a'
if(r2.start != 0.char || r2.size != 0) return "char negative long fail"
if(r2.start != 0.toChar() || r2.size != 0) return "char negative long fail"
val r3 = 'd' downto 'a'
if(r3.start != 'd' || r3.end != 'a' || !r3.isReversed || r3.size != 4) return "char downto fail"
val r4 = 'a' downto 'd'
if(r4.start != 0.char || r4.end != 0.char || !r3.isReversed || r4.size != 0) return "char negative downto fail"
if(r4.start != 0.toChar() || r4.end != 0.toChar() || !r3.isReversed || r4.size != 0) return "char negative downto fail"
return "OK"
}