开发者_如何学运维
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this questionI want to store 2%
in a database as 0.02
. This column was going to be called percent_off
, but now I'm just wondering if math provides a better term for it. Any ideas?
Not convinced on this one, but perhaps quotient. I think it might be worth trying not to think of it as a percentage, but as a fraction, for want of a better way of describing it.
Or, depending on the application domain, that might give a better clue as to a good name.
"Percent" is about as descriptive a value as "Number". It just means that some value was divided by 100, not what that value means in the context.
I doubt that you would create a column titled Number or String or Date, so why call it Percent?
It would be best if you use whatever the meaning of the percent is (discount, interest, quotient) for the name, and not just the type of the data.
How about fraction
? I wonder if discount_of
might be seen as ambiguous: should a 3% discount be stored as 0.03 or as 0.97?
精彩评论