minor fixes and toInt.kyn
This commit is contained in:
47
tests/toInt.kyn
Normal file
47
tests/toInt.kyn
Normal file
@@ -0,0 +1,47 @@
|
||||
fun toInt in {
|
||||
assert $in is <String>
|
||||
let retint = 0
|
||||
let counter = 0
|
||||
let power = ($in size)
|
||||
let size = ($in size)
|
||||
while compare $counter < $size {
|
||||
let char = ($in $counter)
|
||||
power = (math $power - 1)
|
||||
if compare $char == "1" {
|
||||
retint = (math $retint + (math 1 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "2" {
|
||||
retint = (math $retint + (math 2 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "3" {
|
||||
retint = (math $retint + (math 3 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "4" {
|
||||
retint = (math $retint + (math 4 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "5" {
|
||||
retint = (math $retint + (math 5 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "6" {
|
||||
retint = (math $retint + (math 6 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "7" {
|
||||
retint = (math $retint + (math 7 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "8" {
|
||||
retint = (math $retint + (math 8 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "9" {
|
||||
retint = (math $retint + (math 9 * 10 ^ $power))
|
||||
}
|
||||
if compare $char == "0" {
|
||||
# whole lotta nothing
|
||||
}
|
||||
counter = (math $counter + 1)
|
||||
|
||||
}
|
||||
return $retint
|
||||
}
|
||||
let myInt = (toInt "4738927643289")
|
||||
|
||||
println $myInt
|
||||
Reference in New Issue
Block a user