-
Notifications
You must be signed in to change notification settings - Fork 7
max
gicking edited this page Feb 10, 2018
·
4 revisions
back to Command Reference / Math
Calculates the maximum of two numbers.
Notes:
- Because of the way the
max()
function is implemented, using other functions inside the brackets may lead to incorrect results. For example, avoidmax(a++,b)
.
- defined in
misc.h
- auto-loaded in
main_general.h
- no
#define
required
z = max(x, y)
-
input:
- x: the first number, any data type
- y: the second number, any data type
-
output:
- none
- The larger of the two parameter values.
The below code finds the maximum and minimum random number and prints it.
#include "main_general.h"
#include "uart1.h"
#include "putchar.h"
long minVal=INT32_MAX, maxVal=INT32_MIN;
void setup() {
// init UART and printf()
UART1_begin(115200);
putcharAttach(UART1_write);
}
void loop() {
// get random number and check for new min/max
long r = random();
minVal = min(r, minVal);
maxVal = max(r, maxVal);
// every 1s send new found min/max
if ((millis() % 1000) == 0)
printf("%ld %ld\n", minVal, maxVal);
}
- tbd
-
Getting Started
-
- General Commands
- Libraries
- LCD BTHQ21605V
- poti AD5280
- poti AD5282
- freemodbus
- PetitFS SD-card (min)
- FatFS: SD card (full)
- Board Specific
-
- Universal
- Board Specific