Trying to get {File.Megapixel} to be expressed with 1 digit

Started by Damit, April 18, 2025, 03:27:50 AM

Previous topic - Next topic

Damit

No matter how I format it, I cannot get {File.Megapixel} to be expressed with one decimal point.  It always as two. e.g. 12.19 instead of 12.1.

I have tried:
{File.Megapixel|format:"0.0"|cast:int}

{File.Megapixel|math:round,1}

{File.Megapixel|int;format:1;math:round,1}

{File.Megapixel|format:1}

{File.Megapixel|format:2}

{File.Megapixel}

{File.Width|cast:int;
 math:mul,{File.Height|cast:int};
 math:div,1000000;
 format:"0.0"}

{File.Width|cast:int;
 math:mul,{File.Height|cast:int};
 math:div,1000000.0;
 math:round,1}

{File.Width|cast:int;math:mul,{File.Height|cast:int};math:div,1000000.0;format:"0.0"}MP
 and none of them work. ???

Damit

{File.Megapixel||cast:real;math:add,0,1} works, but I cannot figure out why.  I just got lucky trying different options from examples in the manual.

Mario

It's so cool what one can do with IMatch. There is always a way.
But did you consider

{File.Megapixel|numformat:float,1,1}

See numformat:Type, Width {,Decimals}

format is for date and time.

Damit

THANK YOU, Mario!! Yes, you are right, IMatch gives you many paths to forge further! 8)

I was going crazy. I even had chatgpt 4.0,4.5, and O4-mini try and "they" could not figure it out. I tried many permutations. I really don't understand why everybody thinks AI is so awesome, many times I find it costs me more time.  I finally figured out my solution, without the "help" of AI, and even when I fed my solution back to AI, it thought that the "add,0,1" was adding 0.1! That's not even to mention the anthropomorphic excuses it gives me every time is has an "oversight."   >:(

Anyhow, thanks for leading me to the section I re-read like 5 times trying to figure this out. I probably have read that section over 2 dozen times in my 2.5 years of using IMatch. LOL! I missed this, I don't know how, but I am still having trouble understanding what the width portion of this token is doing. This is a first. Even after reading the description and examples I am still having trouble. It's probably me, but maybe the manual could explain things more clearly?
For example, in the manual it states:
"If you use a numformat with a width of 1 and a precision of 5, you get five digits after the decimal point: 0.00313."
I can understand the 5 digits after the decimal point but what is the width of one doing?
Later it states:
"float    Floating point number, e.g. 1.99" but no example of the original number being used to get this value is given. Maybe it is missing?

Later still the manual gives these examples:
...|numformat:float,05,2    07.26
...|numformat:float,05,1    07.3
But I still do not see what the width of 5 is doing.  :-[

If you could be generous enough to explain or send me a link I could use to help me understand it would be greatly appreciated! 
Well I guess AI is good for something! O4-mini gave me this and I want to confirm it is correct: "{File.Megapixel|numformat:float,1,1}, where float is the type, 1 is the width (minimum digits before the decimal), and the final 1 is the number of decimals."
So, width is the digits before the decimal, correct?