yihui/xfun

In joining number words by and

msgoussi opened this issue · 5 comments

xfun::numbers_to_words(1500780)
[1] "one million, five hundred thousand, seven hundred eighty"
I guess it should be
[1] "one million, five hundred thousand, seven hundred and eighty"

also
xfun::numbers_to_words(1500780.95)
Error in xfun::numbers_to_words(1500780.95) :
The numbers must be integer.
i guess it should be
one million, five hundred thousand, seven hundred eighty and ninety five hundredths

Thanks.

yihui commented

Can anyone help? (perhaps @daijiang?)

For the first one, use xfun::numbers_to_words(1500780, and = TRUE).

For the second one, currently, xfun::numbers_to_words() only works for integers. I am not sure how likely people want to spell out numbers that are not integers.

> xfun::numbers_to_words(1500780.95)

I had to search the grammar rules for this and the common convention is to pronounce it as one million, five hundred thousand, seven hundred eighty point nine five.

@yihui If this sounds appropriate, I can help implement it.

yihui commented

@harshvardhaniimi Sure! We appreciate it.

Sorry for the year-long radio silence on this. I've created a pull request for this. I'm not experienced at this so if any changes are needed, please suggest them. Thanks!