View Single Post
Old 05-21-2022, 05:45 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,487
Karma: 8025704
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by w00dent0p View Post
Thanks, that explains it. I already went with choice 2.

Can you please clarify the template meaning a little more? Is there a way to achieve a consistent format across both float and integer? i.e. xx.x for both?
Sure. If you *know* that you want xx.x and never xx.xx or xx then this does it.
Code:
{author_sort}/{series}/{series_index:format_number(0.1f)} {title} - {authors}
The original template checked to see if the index was a float by comparing its value to its 'floor' (integer part). If they are not the same then if used format_number() to convert it using 2 digits after the decimal, otherwise it used it unchanged. The new template (above) always converts it to use 1 digit after the decimal point regardless of whether it is integer or float.

Also and FWIW: the first template uses Template Program Mode. The one in this post uses Single Function Mode. My personal preference is General Program Mode, but I didn't provide an example in that mode.
chaley is offline   Reply With Quote