View Single Post
Old 06-26-2019, 08:01 AM   #10
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Soap-dodger View Post
You are so kind; your solution works excellently.

I am having difficulty in converting the result to an integer. I have read the relevant section of the Calibre manual to no avail. Here's what I've tried so far:

Code:
format_number(divide(words,pages), {0:3.0f});
format_number(divide(words,pages), "{0:3.0f}");
format_number(divide(words,pages), {0:,d});
format_number(divide(words,pages), "{0:,d}");
Either the manual could be clearer or I'm missing something.

Please, can you advise where I've got it wrong?
The one that worked for me was:

Code:
format_number(divide(words,pages), "{0:3.0f}");
But, if you do it in template mode, you need to remove the braces. So, it would be:
Code:
{:'format_number(divide(cmp(raw_field("#pages"),0,0,0,raw_field("#words")),cmp(raw_field("#pages"),0,1,1,raw_field("#pages"))), "3.0f")'}
davidfor is offline   Reply With Quote