api: Fix operator precedence and conversion

Problem:
  - commit 89088fe37d9a21c1fd7c6c372e3f91b8acaf8b2c contained a wrong
    fix for the second problem with operator precedence as well as an
    issue regarding implicit type conversion

Solution:
  - Fix the parentheses to realise the desired operator precedence
  - Explicitly cast to avoid a conversion warning