mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
address issue 24: floating point spelling
This commit is contained in:
@@ -116,16 +116,15 @@ class Num2Word_Base(object):
|
||||
|
||||
pre = int(value)
|
||||
post = abs(value - pre)
|
||||
post *= 10**self.precision
|
||||
|
||||
out = [self.to_cardinal(pre)]
|
||||
if self.precision:
|
||||
out.append(self.title(self.pointword))
|
||||
|
||||
for i in range(self.precision):
|
||||
post *= 10
|
||||
curr = int(post)
|
||||
out.append(str(self.to_cardinal(curr)))
|
||||
post -= curr
|
||||
curr = str(post)[i]
|
||||
out.append(str(self.to_cardinal(int(curr))))
|
||||
|
||||
return " ".join(out)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user