View Single Post
Old 12-26-2019, 02:08 PM   #10
Kythe42
Zealot
Kythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipseKythe42 can illuminate an eclipse
 
Kythe42's Avatar
 
Posts: 122
Karma: 8440
Join Date: Aug 2013
Device: Android tablet
It's basically what you suggested with just the percent symbol added in but removing it didn't fix the problem.

Code:
program:
	read = raw_field('#pages_read');
	total = raw_field('#total_pages');
# if total <= 0 (or undefined), set read to 0
	read = cmp(total, 0, 0, 0, read);
# make sure the dividend (total) != 0 
	total = cmp(total, 0, 1, 1, total);
	percent = multiply(divide(read, total), 100);
	cmp(percent, 0, '', '', format_number(percent, "{0:2d}%"))
The #pages_read and #total_pages custom columns are integers.
Kythe42 is offline   Reply With Quote