Min()

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

Take the minimum value.

Take the minimum between two numbers. For example:

sensVal = min(sensVal, 100); // assigns sensVal to the smaller of sensVal or 100
                             // ensuring that it never gets above 100.

[Return to Arduino Syntax Manual]