TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

2 点作者 escot超过 1 年前
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 条评论

warrenm超过 1 年前
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`?
PaulHoule超过 1 年前
Just &quot;fraction&quot;.
bell-cot超过 1 年前
&quot;rate&quot;, or &quot;tax_rate&quot;, or &quot;state_rate&quot;, or &quot;state_tax_rate&quot;.
warrenm超过 1 年前
&gt;No one is writing taxRateDecimalFraction as a var name.<p>Wait til you see Java or Hungarian Notation