When there are more than integer numbers, it is often necessary to make them colloquial more intuitive. Next we will share two pieces of code: python and js pythondeffn (num): The number Port... when there are more than integer numbers, they are often more intuitive to colloquial. Below are two pieces of code: python and js
Python
Def fn (num): ''' colloquial number ''' ret = ''num = int (num) if num/10000 = 0: ret = str (num) else: if num/10 ** 8 = 0: if num % 10000! = 0: ret = str (num/10000) + 'wan' + str (num % 10000) else: ret = str (num/10000) + 'wan' else: n2 = num % 10 ** 8 if n2 % 10000! = 0 and n2/10000! = 0: ret = str (num/10 ** 8) + 'yi' + str (n2/10000) + 'wan' + str (n2% 10000) elif n2 % 10000! = 0 and n2/10000 = 0: ret = str (num/10 ** 8) + '100 '+ str (n2% 10000) elif n2 % 10000 = 0 and n2/10000! = 0: ret = str (num/10 ** 8) + 'yi' + str (n2/10000) + 'wan' elif n2 % 10000 = 0 and n2/10000 = 0: ret = str (num/10 ** 8) + 'yie' return ret
Javascript:
Function int2string (num) {num = Number (num); if (num/10000 <1) {ret = num;} else {if (num/Math. pow (10000) <1) {if (num %! = 0) {ret = parseInt (num/10000) + 'wan' + num % 10000;} else {ret = parseInt (num/10000) + 'wan ';}} else {n2 = num % Math. pow (10000); if (n2 %! = 0 & n2/10000! = 0) {ret = parseInt (num/Math. pow (10000) + 'yie' + parseInt (n2/10000) + 'wan' + (n2% 10000);} else if (n2 %! = 0 & n2/10000 = 0) {ret = parseInt (num/Math. pow (10000) + '100 '+ parseInt (n2% 10000);} else if (n2% 10000 = 0 & n2! = 0) {ret = parseInt (num/Math. pow (10000) + 'Hundred million '+ parseInt (n2/10000) + 'wan';} else if (n2% 10000 = 0 & n2/= 0) {ret = (num/Math. pow () + '100 million ';}} return ret}