Numbers Flashcards
What are the possible simple arithmetic operation we can do with PHP?
$a + $b
$a - $b
$a * $b
$a / $b
$a % $b
How do you do the assignment and operation at the same time?
para decir $a = $a + $b
$a += $b
Which ones are the incremental operators?
$a++
++$a
Which ones are the decrement operators?
$a–
–$a
How do you convert a string into number?
if I have $strnum=’12’
floatval($strnum)
o
intval($strnum)
Which ones are the most common number functions?
- abs(-15)
- paw(2,3)
- sqrt(16)
- max(2,3)
- min(2,3)
- round(2.6) => 3
round(2.4) => 2 - floor(2.6) => 6
- ceil(2.4) => 3
How do you get the absolute number?
abs(-15)
How do you get a number elevated to another number?
pow(2,3)
=> me daria 8 porque es 222
Como obtengo la raiz cuadrada de un número?
sqrt(16)
How do I get the maximum number of a range of numbers?
max(2,3,4,5,6)
separo los numeros por coma
How do i get the minimum number of a range of numbers?
min(2,3,4,5,6)
los separo por comas
Como funciona el método round()?
si es < a .5 redondea para abajo, y si es >= .5 redondea para arriba.
Entonces
round(2.5) va a ser igual a 3
y
round(2.4) va a ser igual a 2
How do I make it always to round down?
with floor()
floor(2.6) => 2
How do I make it always round up?
with ceil()
ceil(2.4) => 3
How can you change the format of a number?
number_format($number,number of decimals, ‘qué separa los decimales’, ‘qué separa los miles’)
$number=123456789,123
number_format($number,2, ‘,’,’ ‘)
=>
123 456 789,12