AgerNic.com/ro
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
Tutorial

Tutorial PHP» Numere

În acest capitol vom analiza în profunzime numere întregi, numere reale ?i ?iruri de numere.

Php numere Intregi.
Un num?r întreg este un num?r f?r? nicio parte zecimal?.

2, 220, -220, 10345, -128965 sunt numere întregi. În timp ce 7.46, 11.2, 112.77 sunt numere reale.

Deci, un tip de date întreg este un num?r non-zecimal cuprins între -2147483648 ?i 2147483647. O valoare mai mare (sau mai mic?) decât aceasta, va fi stocat? ca numar real, deoarece dep??e?te limita unui num?r întreg.

Un alt lucru important de ?tiut este c?, chiar dac? 2 *4 .5 este 9, rezultatul este stocat sub form? de numar real, deoarece unul dintre operanzi este un numar real(2.5).

Iat? câteva reguli pentru numere întregi:

Un num?r întreg trebuie s? aib? cel pu?in o cifr?
Un num?r întreg nu trebuie s? aib? o zecimal?
Un num?r întreg poate fi pozitiv sau negativ
Numerele întregi pot fi specificate în trei formate: zecimale (bazate pe 10), hexadecimale (bazate pe 16 - prefixate cu 0x) sau octale (pe baza 8 - prefixate cu 0)
PHP are urm?toarele func?ii pentru a verifica dac? tipul unei variabile este întreg:

is_int()
is_integer() - alias of is_int()
is_long() - alias of is_int()

Exemplu
Verifica?i dac? tipul unei variabile este întreg:

<?php 
$x =5985;
var_dump(is_int($x));

$x =59.85;
var_dump(is_int($x));
?>

PHP Numere Reale

Un numar real este un num?r cu un punct zecimal sau un num?r în form? exponen?ial?.

Exemplu: 2.0, 256.4, 10.358, 7.64E + 5, 5.56E-5 sunt toate numere reale..

Tipul de date reale poate stoca de obicei o valoare de pân? la 1.7976931348623E + 308 (dependent? de platform?) ?i are o precizie maxim? de 14 cifre.

PHP are urm?toarele func?ii pentru a verifica dac? tipul unei variabile este reala:

is_float()
is_double() - alias of is_float()

Exemplu
Verifica?i dac? tipul unei variabile este real (float):

<?php
$x =11.325;
var_dump(is_float($x)); echo "<br />";

$y =11;
var_dump(is_float($y)); echo "<br />";

$z=234.34;
var_dump(is_float($z));
?>

PHP valoare infinita
O valoare numeric? mai mare decât PHP_FLOAT_MAX este considerat? infinit?.

PHP are urm?toarele func?ii pentru a verifica dac? o valoare numeric? este finit? sau infinit?:

is_finite ()
is_infinite ()

Cu toate acestea, func?ia PHP var_dump () returneaz? tipul ?i valoarea datelor:

Exemplu
Verifica?i dac? o valoare numeric? este finit? sau infinit?:


<?php
$x = 1.9e411;
var_dump($x);
echo "<br />";

$y=1.2e220;
var_dump($y);
?>

Tags: PHP numere, numbers

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


analytics piwika