Max()

From Microduino Wiki
Revision as of 10:11, 16 August 2016 by Fengfeng (talk) (Created page with "<pre style="color:green"> #define max(a, b) ((a)>(b)?(a):(b)) </pre> The maximum value<br> Take the maximum between two numbers, for example:<br> <pre style="color:green"> se...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#define max(a, b) ((a)>(b)?(a):(b))

The maximum value

Take the maximum between two numbers, for example:

sensVal = max(senVal, 20); // assigns sensVal to the larger of sensVal or 20
                           // (effectively ensuring that it is at least 20)

[Return to Arduino Syntax Manual]