I guess I'll have to be lenient on the use of "and", cause ya know, the Britts gotta be different. I was taught in Math class that 'and' was only used to represent the decimal, which makes sense to me.
2.5 days left, so I thought I'd share mine now that others have gotten there out there . No decimal support in mine either. I added negative and zero but code function is still under 40 if you're not counting the arrays.
dim _ones[9] as string = ["one","two","three","four","five","six","seven","eight","nine"]
dim _tens[8] as string = ["twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"]
dim _teens[10] as string = ["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"]
//dim _place[22] as string = ["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion","centillion"]
dim _place[18] as string = ["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion"]
dim avg[10] as integer
n$ = "-50,001,475,171,417"
f$ = dictateNumber(n$)
repeat
print(n$)
print(f$)
inc j
t = getMilliseconds()
for i = 1 to 10000
dictateNumber(n$)
next i
t = getMilliseconds() - t
avg[j] = t
if j = 10 then j = 0
n = 0
print("---------")
for i = 1 to 10
n = n + avg[i]
print(avg[i])
next i
print("---------")
n = n / 10
print("avg:"+str(n))
Sync()
until getRawKeyPressed(27) = 1
end
function dictateNumber(number as string)
if number = "0" then exitfunction "zero"
n$ = stripCommas(number)
place = 0
final$ = ""
L = len(n$)
for i = 1 to L step 3
x$ = right(n$, 3)
while len(x$) < 3 : x$ = "0" + x$ : endwhile
n$ = left(n$, len(n$)-3)
words$ = ""
hund = val(mid(x$,1,1))
tens = val(mid(x$,2,1))
ones = val(mid(x$,3,1))
if hund > 0 then words$ = words$ + _ones[hund-1] + " hundred "
if tens > 1
words$ = words$ + _tens[tens-2] + " "
if ones > 0 then words$ = words$ + _ones[ones-1]
elseif tens = 1
words$ = words$ + _teens[ones] + " "
elseif tens = 0
if ones > 0 then words$ = words$ + _ones[ones-1]
endif
if len(words$) > 0
if place > 0 : p$ = words$ + " " + _place[place-1] + " " : else : p$ = words$ : endif
endif
final$ = p$ + final$
inc place
next i
if mid(number, 1, 1) = "-" then final$ = "negative "+final$
endfunction final$
function stripCommas(n as string)
number as string
for i = 1 to len(n)
c$ = mid(n, i, 1)
if asc(c$) > 47 and asc(c$) < 58 then number = number + c$
next i
endfunction number
"I like offending people, because I think people who get offended should be offended." - Linus Torvalds