Millisecond Forums

Converting to pixels

https://forums.millisecond.com/Topic15002.aspx

By Kolfers - 11/16/2014

Hi, 

I spent some time figuring out why my dynamic positioning didn't work. In the end I realized this does not work: 
/ position = (900 * 1px, 900 * 1px)

however this does:
/ position = (1px * 900,1px * 900)


Is there a reason why the order of the components matters? 

Thank you!

Kerwin
By Dave - 11/16/2014

Yes, order matters. The unit of the first term determines the unit of the result:

1px * 400 -> result will be interpreted as pixels
400 * 1px -> result will  be interpreted as pure integer (no unit)

The reason this matters is that there must be a way to deal with terms with different units. E.g, should 1px * 400pct return a result in pixels or percentages? The order of the terms allows you/ the program to decide that.