4 ms·
It's worth noting that the programmer who wrote this string-based numerical rounding procedure: # round to one decimal place and # separate into whole and fra
by pius 19y ago
It's worth noting that the programmer who wrote this string-based numerical rounding procedure:
# round to one decimal place and
# separate into whole and fractional parts
parts = str(round(star_sum/num_raters, 1)).split('.')
whole = int(parts[0])
frac = int(parts[1])
if frac < 3:
___frac = 0
elif frac > 7:
___frac = 0
___whole += 1
else:
___frac = 5
# recombine for a star rating rounded to the half
stars = float(str(whole)+'.'+str(frac))
is running a pretty famous startup.