I have a variable that sets a percentage:
@var-a: 50%;
And another that is a fixed width:
@var-b: 100px;
I want to calculate @var-c as below:
@var-c: (@var-a * @var-b);
I expected 50px, but actually get 5000px. What am I doing wrong?
Less calculations use the numbers regardless of the units. If you know that @var-a will be in percentages, you could just do something like this:
@var-c: unit(@var-a / 100 * @var-b, px);
using unit() allows you to control the output unit.
You can also use guards in addition to do something else if @var-a isn't a percentage.
@var-byou should just have@var-a : 0.5, percentages are used in the context of the client page width.