Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable name percent from 0 to 1

So this seems like I should have been wondering about this when I first started programming, but I suppose back then I wasn't as concerned with 'perfect' variable naming.

So I have the variables

float lifeTime; float age;

Where lifeTime is the full lifeTime of my object, age the current lifeTime of the object. The object will die when age reaches the full lifeTime.

I was just creating a variable, ranging from 0 to 1, defining the progress of age compared to the full lifeTime. agePercent, if you will. Of course agePercent isn't correct though, as this ranges from 0 to 1.

After reading some other posts about ageFraction, ageGradient, ageNormalized, I felt like none of these fit the purpose.

My solution is agePerunum, simply using latin (I believe it's correct, but I dropped out in highschool). So my question is... is that cool? Does that make sense to you as a programmer? Any thoughts or maybe better ideas?

http://mymemory.translated.net/en/Latin/English/per-unum

like image 864
user3294236 Avatar asked Feb 21 '17 05:02

user3294236


People also ask

Can percent be a variable name?

Note that each Variable name is enclosed by percentage signs ('%'). The percentage sign is used as a special character; its most common use is to denote variables.

What variable is percentage?

Nominal variables are often summarized as proportions or percentages.

How do you name variable numbers?

A variable name must start with a letter or the underscore character. A variable name cannot start with a number. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables)


1 Answers

One idea is to make agePercent equal to an actual percentage, so 37 instead of 0.37. But that might make other calculations in your code require an unnecessary conversion step.

Proportion and portion are nouns you could suffix age with. Proportion means the relation of one part to another or to the whole with respect to magnitude, quantity, or degree. Portion means an often limited part of a whole. So ageProportion or agePortion? First one sounds better.

like image 106
at. Avatar answered Sep 21 '22 18:09

at.