Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,93 @@
class NumberNames {
small : static : String[];
tens : static : String[];
big : static : String[];
function : Main(args : String[]) ~ Nil {
small := ["one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen"];
tens := ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"];
big := ["thousand", "million", "billion", "trillion"];
Int2Text(900000001)->PrintLine();
Int2Text(1234567890)->PrintLine();
Int2Text(-987654321)->PrintLine();
Int2Text(0)->PrintLine();
}
function : native : Int2Text(number : Int) ~ String {
num := 0;
outP := "";
unit := 0;
tmpLng1 := 0;
if (number = 0) {
return "zero";
};
num := number->Abs();
while(true) {
tmpLng1 := num % 100;
if (tmpLng1 >= 1 & tmpLng1 <= 19) {
tmp := String->New();
tmp->Append(small[tmpLng1 - 1]);
tmp->Append(" ");
tmp->Append(outP);
outP := tmp;
}
else if (tmpLng1 >= 20 & tmpLng1 <= 99) {
if (tmpLng1 % 10 = 0) {
tmp := String->New();
tmp->Append(tens[(tmpLng1 / 10) - 2]);
tmp->Append(" ");
tmp->Append(outP);
outP := tmp;
}
else {
tmp := String->New();
tmp->Append(tens[(tmpLng1 / 10) - 2]);
tmp->Append( "-");
tmp->Append(small[(tmpLng1 % 10) - 1]);
tmp->Append(" ");
tmp->Append(outP);
outP := tmp;
};
};
tmpLng1 := (num % 1000) / 100;
if (tmpLng1 <> 0) {
tmp := String->New();
tmp->Append(small[tmpLng1 - 1]);
tmp->Append(" hundred ");
tmp->Append(outP);
outP := tmp;
};
num /= 1000;
if (num = 0) {
break;
};
tmpLng1 := num % 1000;
if (tmpLng1 <> 0) {
tmp := String->New();
tmp->Append(big[unit]);
tmp->Append(" ");
tmp->Append(outP);
outP := tmp;
};
unit+=1;
};
if (number < 0) {
tmp := String->New();
tmp->Append("negative ");
tmp->Append(outP);
outP := tmp;
};
return outP->Trim();
}
}