Announcement

Collapse
No announcement yet.

How to define negative constant value

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to define negative constant value

    Hi,
    From the title, the answer seems obvious; but, if I define a costant like
    Code:
    #constant ABSOLUTE_MIN -514
    the result is that, when I use the constant, the compiler warns "32 bit operand truncated to 16 bits".
    How can I resolve it?
    Pietro

  • #2
    Hi Pietro,

    Commonly, constants are non-negative values and also constants are like a variable. In 4DGL, every variable use 16-bit signed integer of data with values ranging -32768 to 32767 as described here: Arduino Data types

    Defining a constant with a negative value appears that the compiler will show a warning.

    Here's my way:
    Code:
    #constant ABSOLUTE_MIN 32767 + 32767 + 2  + (your negative value here)
    Example:
    Code:
    #constant ABSOLUTE_MIN 32767 + 32767 + 2  + (-514)


    If you have questions, please don't hesitate to ask here.

    Best regards,
    Kayven

    Comment

    Working...
    X