Skip to content

Update max.adoc #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions Language/Functions/Math/max.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ subCategories: [ "Math" ]
--

[float]
=== Description
Calculates the maximum of two numbers.
=== Descrizione
Calcola il massimo di due numeri.
[%hardbreaks]


[float]
=== Syntax
=== Sintassi
`max(x, y)`


[float]
=== Parameters
`x`: the first number, any data type
`y`: the second number, any data type
=== Parametri
`x`: il primo numero, qualsiasi tipo di dati
`y`: il secondo numero, qualsiasi tipo di dati

[float]
=== Returns
The larger of the two parameter values.
=== Restituisce
Il maggiore dei due valori.

--
// OVERVIEW SECTION ENDS
Expand All @@ -46,28 +46,28 @@ The larger of the two parameter values.
--

[float]
=== Example Code
=== Codice di esempio
// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
The code ensures that sensVal is at least 20.
Il codice garantisce che sensVal sia pari almeno a 20.

[source,arduino]
----
sensVal = max(senVal, 20); // assigns sensVal to the larger of sensVal or 20
// (effectively ensuring that it is at least 20)
sensVal = max(senVal, 20); // assegna a sensVal il valore maggiore tra sensVal e 20
// (garantendo di fatto che sia almeno 20)
----
[%hardbreaks]

[float]
=== Notes and Warnings
Perhaps counter-intuitively, `max()` is often used to constrain the lower end of a variable's range, while `min()` is used to constrain the upper end of the range.
=== Note e avvertenze
Per quanto possa essere controintuitivo, `max()` viene spesso utilizzato per limitare l'estremo inferiore dell'intervallo di una variabile, mentre `min()` viene utilizzato per limitare l'estremo superiore di un intervallo.

Because of the way the `max()` function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results
Per via del modo in cui la funzione `max()` è implementata, è bene evitare l'uso di altre funzioni all'interno delle parentesi, che potrebbe condurre a risultati errati
[source,arduino]
----
max(a--, 0); // avoid this - yields incorrect results
max(a--, 0); // evita di farlo: produce risultati errati

max(a, 0); // use this instead -
a--; // keep other math outside the function
max(a, 0); // usa invece questo:
a--; // mantenendo gli altri calcoli al di fuori della funzione
----

--
Expand Down