貨幣轉英文

2021-04-25 05:23:04 字數 3402 閱讀 4122

由三個函式組成。

function inten(n: integer): string;

var s: string;

begin

case n of

0: s := '';

1: s := ' one';

2: s := ' two';

3: s := ' three';

4: s := ' four';

5: s := ' five';

6: s := ' six';

7: s := ' seven';

8: s := ' eight';

9: s := ' nine';

else

s := ' xx';

end;

result := s;

end;

function inhundred(n: integer): string;

var s: string;

begin

case n of

0: s := '';

1..9: s := inten(n);

10: s := ' ten';

11: s := ' eleven';

12: s := ' twelve';

13: s := ' thirteen';

14: s := ' fourteen';

15: s := ' fifteen';

16: s := ' sixteen';

17: s := ' seventeen';

18: s := ' eighteen';

19: s := ' nineteen';

20..29: s := ' twenty' + inten(n - 20);

30..39: s := ' thirty' + inten(n - 30);

40..49: s := ' forty' + inten(n - 40);

50..59: s := ' fifty' + inten(n - 50);

60..69: s := ' sixty' + inten(n - 60);

70..79: s := ' seventy' + inten(n - 70);

80..89: s := ' eighty' + inten(n - 80);

90..99: s := ' ninety' + inten(n - 90);

else s := ' ***';

end;

result := s;

end;

function translatecurrent(num: double): string;

varln: longint;

n1, n2, n3, n4, n5, rn: integer;

s: string[255];

begin

s := '';

rn := round(abs(num - trunc(num)) * 100);

(*rn := round(abs(frac(num)*100));*)

ln := trunc(num);

(*ln := round(num);*)

n1 := ln mod 100; ln := ln - n1;

n2 := trunc(ln / 100) mod 10; ln := ln - (trunc(n2) * 100);

n3 := trunc(ln / 1000) mod 100; ln := ln - (trunc(n3) * 1000);

n4 := trunc(ln / 100000) mod 10; ln := ln - (trunc(n4) * 100000);

n5 := trunc(ln / 1000000) mod 100;

if n5 > 0 then s := s + inhundred(n5) + ' million';

if n4 > 0 then s := s + inhundred(n4) + ' hundred';

if (n4 > 0) and (n3 = 0) then s := s + ' thousand';

if n3 > 0 then s := s + inhundred(n3) + ' thousand';

if n2 > 0 then s := s + inhundred(n2) + ' hundred';

if n1 > 0 then s := s + inhundred(n1);

if rn > 0 then s := s + ' and cents ' + inhundred(rn);

result := s;

end;

function translatedouble(num: double): string; //dick lee source code;

varln: longint;

n1, n2, n3, n4, n5, rn: integer;

s: string[255];

begin

s := '';

rn := round(abs(num - trunc(num)) * 100);

(*rn := round(abs(frac(num)*100));*)

ln := trunc(num);

(*ln := round(num);*)

n1 := ln mod 100; ln := ln - n1;

n2 := trunc(ln / 100) mod 10; ln := ln - (trunc(n2) * 100);

n3 := trunc(ln / 1000) mod 100; ln := ln - (trunc(n3) * 1000);

n4 := trunc(ln / 100000) mod 10; ln := ln - (trunc(n4) * 100000);

n5 := trunc(ln / 1000000) mod 100;

if n5 > 0 then s := s + inhundred(n5) + ' million';

if n4 > 0 then s := s + inhundred(n4) + ' hundred';

if (n4 > 0) and (n3 = 0) then s := s + ' thousand';

if n3 > 0 then s := s + inhundred(n3) + ' thousand';

if n2 > 0 then s := s + inhundred(n2) + ' hundred';

if n1 > 0 then s := s + inhundred(n1);

if rn > 0 then s := s + ' and cents ' + inhundred(rn);

result := s;

end;

數字轉英文

金融業最熟悉也最敏感的就是 數字 中文和英文的數字單位用法不盡相同,中文說 1 億 英文說 one hundred million 100 個百萬 金融人要熟悉這樣的差異,同時也能馬上理解外國人口說的英文數字,即為打好金融英文基礎的第一步。照此練習,短短一小時,就能破除中英文數字轉換的魔咒,讓開會時...

php 轉 英文時間 參考

echo 時間格式1 date y m d h i s 2010 06 12 10 26 31 echo 時間格式2 date y m d h i s 10 jun sat 10 43 th echo 月份,英文全名 date f june echo 月份,二位數字,補零 date m 06 ech...

c 實現貨幣轉中文大寫類

using system using system.collections.generic using system.linq using system.text namespace hm ykt public money double m 判斷輸入的數字是否大於double型別 private b...