isinf()
[Math]
bool isinf(double x);Description
Returns true if x is infinite,
false otherwise.
Parameters
x: The value to check if it is infinite.
Returns
true if x is infinite, false
otherwise.
Example Code
The code reads the value of two potentiometers connected to pins
INX and INY and places true on
pin OUT if the $\frac{x}{y}$ is infinite, false
otherwise.
void setup() {
pinLabel(0, "INY"); // set the label of pin 0 to "INY"
pinLabel(1, "INX"); // set the label of pin 1 to "INX"
pinLabel(2, "OUT"); // set the label of pin 2 to "OUT"
pinMode(2, OUTPUT); // set pin 2 as output
pinLabel(3, "OUT2"); // set the label of pin 3 to "OUT2"
pinMode(3, OUTPUT); // set pin 3 as output
pinLabel(4, "VCC"); // set the label of pin 3 to "VCC"
powerPin(4); // set pin 4 as power pin
pinLabel(5, "GND"); // set the label of pin 4 to "GND"
groundPin(5); // set pin 5 as ground pin
}
void loop() {
int val_x = analogRead(0); // read the value of the potentiometers
int val_y = analogRead(1);
// map the value of the potentiometers from 0 to 1023
// to the range of 0 to 10
double x = map(val_x, 0, 1023, 0, 10);
double y = map(val_y, 0, 1023, 0, 10);
bool z = isinf(x / y); // check if x/y is infinite
digitalWrite(2, z); // write the value of z to pin 2
}