Jump to content
You must now use your email address to sign in [click for more info] ×

1.7.0.3 Numerical fields - division failing when units are specified


Recommended Posts

  • 2 weeks later...
  • Staff

What would you expect 100 / 2px to do?  What is 100 divided by 2 apples? It makes no sense.

"(100 / 2) px" has the precedence of calculating the 100 / 2, then assigning the unit type - which is why that works.  The unit type has higher precedence that the arithmetic operators - which is why you need the brackets.

This is not a regression - I've tightened up the rules on how units types can be automatically assigned to pure values.

 

What should the 100 be up-converted to?  px?  What if the document units are in mm?  What then?  Should it be px or mm??

 

In equations where you have expressed units, the operands for / need to be the same type, or the RHS must be a scalar.  For the operators (+ - *) the unit type can be up-converted to match the document units if the other operand is a distance type.

 

If the result of an expression is a pure number, we allow the conversion to the unit type of the document.

SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB
Link to comment
Share on other sites

  • Staff

In 1.7 it should reject it, as the result should be a strict pure number.  If you wrote "(20mm / 10mm) in" it would explicitly convert the number to the literal inches value.

SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB
Link to comment
Share on other sites

  • Staff

This seems to be part of the current debate on how expressions should work.  Users want it to intuitively convert some unassigned numbers, but there are going to be times when the automatic conversion just doesn't make sense, or the unit type used is not what the user expected.

 

 

Division is the one tricky area - dividing two values of same type should produce a ratio - a pure nunber, but dividing a unit by a pure number should result in a unit.  It also stems from the fact we have no concept of square units.  So 2mm * 2mm = 4mm, instead of 4mm^2.  So sqrt(100mm) equals 10mm.

SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.