Given the file name foo/bar.baz
, we can say that foo/
is the dirname, bar.baz
is the basename and .baz
is the extname. But is there a similar term that we can use for the foo/bar
or bar
part — i.e., the “file name sans extension”?
I have been using "mantissa" in my code's comments for years. For a computer floating point number the mantissa is just the numbers without the power. I think of the extension as like the power.
Example: 123E56 where the mantissa is 123
1.23E56 is not a correct form and needs to be adjusted to 123E54 and once again the mantissa is 123
So for floating point numbers that have a first part which contains a decimal point the power simply needs to be adjusted to move the decimal point all the way to the right.
Also there is a key stoke on some HP calculators that will show the mantissa with all digits without the power.
So for filenames when I leave the extension off what is left is the mantissa. And the period is not included in the mantissa just like it is not included in a floating point number(depending on the type of floating point representation that is.)
foo.bar : the mantissa is foo
A similar logic can be used for the logarithm mathematical use of the term mantissa that I think also parallels to filenames.
I hope this catches on because we really need a name for that part. And I vote for "mantissa" since I already have thousands of lines of code with comments using "mantissa" and I'm not going to change them. Like anyone reads my comments anyway. I write a comment line for just about every line of code. And I create a flow chart file as well.
base name
wikipedia/Filename ruby/File#basename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With