TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Naming convention for a percentage stored as a value from 0 to 1

2 pointsby escotover 1 year ago
Say you’re storing a percentage like “state tax”. You store it as a decimal: 0.4 means 40%. What do you call this type when you need to name a db column or a variable? Technically it is not a percent until you * 100.<p>“Decimal fraction” seems most correct but is very verbose. No one is writing taxRateDecimalFraction as a var name.

4 comments

warrenmover 1 year ago
how about `taxrate`?<p>Or don&#x27;t store it as a decimal between 0 and 1 - but as a value between 0 and 100 (with possible decimal points, of course), and just call it `taxpct`?
PaulHouleover 1 year ago
Just &quot;fraction&quot;.
bell-cotover 1 year ago
&quot;rate&quot;, or &quot;tax_rate&quot;, or &quot;state_rate&quot;, or &quot;state_tax_rate&quot;.
warrenmover 1 year ago
&gt;No one is writing taxRateDecimalFraction as a var name.<p>Wait til you see Java or Hungarian Notation