Consider that I have a variable of
type:Real, and I want to turn the result into an integer that is not 'rounded up' to the next digit, like this:
Raw Value | Integer not 'rounded up' |
7.4 | 7 |
2.8 | 2 |
8.9 | 8 |
4.3 | 4 |
However, using
{File.AT.Video Files.IMDB Rating|cast:int}, my output is 'rounded up' to the next digit, like this:
Raw Value | Formatted with |cast:int |
7.4 | 7 |
2.8 | 3 |
8.9 | 9 |
4.3 | 4 |
So, what argument can I use for the variable to give me output like in the 1st table? Thanks.
In the help is a lot written about such things, like:
If you work with real/floating point numbers, specify digits as 2 or more. Else the decimals will be trimmed and, for example, a result like 3.1415926 is retourned as 3.
With 2 digits you'll get 3.14 and with 4 digits you'll get 3.1416
Maybe you can find there a solution.
If it is an IMDB rating my assumption would be that the values are between 0 (including) and 10 (excluding). So just one digit before the decimal point. Maybe you can use substr?
You should be able to use this trick:
{File.AT.TestDarius.IMDB Rating|math:add,0}
If you look at the help for math (https://www.photools.com/help/imatch/var_basics.htm#a_format?dl=h-229), you will find this information:
If you work with real/floating point numbers, specify digits as 2 or more. Else the decimals will be trimmed and, for example, a result like 3.1415926 is returned as 3. With 2 digits you'll get 3.14 and with 4 digits you'll get 3.1416.
Thinking a bit backwards, this means that one can intentionally leave out the digits argument, so that the Real variable is truncated or trimmed. Adding 0 does not change the value, so I think this should work.
That's interesting. Thanks Thorsten.
Thorsten, that is exactly what I came up with! (After spending some time examining the part of the help file that Markus (and, now, you) quoted)
What it boils down to is that with the math arguments (probably should have been called arithmetic arguments from the get-go), one can add or subtract 0, or one can divide or multiply by 1. I just divided by 1 ;D
So, thanks to Markus and Thorsten!
Finally, Darius, you got it! Cool! :)
I use these math argument quite a lot, they are very useful solving a lot of problems.