A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 113

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 280

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 145

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 223

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 303

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 344

A PHP Error was encountered

Severity: 8192

Message: setcookie(): Passing null to parameter #7 ($httponly) of type bool is deprecated

Filename: core/Input.php

Line Number: 410

floor() ceil() ve round() Fonksiyonları Kullanımı (Sayı Yuvarlama Fonksiyonları)
Öneri ve Hata Raporu



Günün Sözü Sevemez kimse seni benim sevdiğim kadar

kategori PHP
oylama 3.1/5 yorum 0 yorum yazar Hakan Taşan tarih 16 Ağustos 2015

PHP ile sayı yuvarlama fonksiyonlarına göz atacağız. Zaman zaman kullanışlı olan fonksiyonlardır. Ondalıklı sayıları tam sayıya çevirmeye ve bazen de küsuratlarından kurtarmaya yararlar. Çoğunlukla matematiksel işlemlerde ve oran hesaplamalarında kullanılır. Çok detaya girmeden floor() ceil() ve round() fonksiyonlarının tanımlarına ve örneklerine geçelim.

floor() Fonksiyonu: Sayıyı bir altındaki tam sayıya yuvarlar.

ceil() Fonksiyonu: Sayıyı bir üstündeki tam sayıya yuvarlar.

round() Fonksiyonu: Sayıyı yuvarlamak için bir tam sayının orta noktası baz alınır. Eğer sayının ondalık kısmı 0 ile 4 arasındaysa bir altındaki tam sayıya, 5 ile 9 arasındaysa bir üstündeki tam sayıya yuvarlar.

Not: Ondalıklı sayıları yazarken virgül ile değil nokta ile yazmalısınız.

Örnekler

echo floor(1.1);    // Çıktı: 1
echo floor(1.19);    // Çıktı: 1
echo floor(1.5);    // Çıktı: 1
echo floor(1.55);    // Çıktı: 1
echo floor(1.9);    // Çıktı: 1
echo floor(1.91);    // Çıktı: 1

echo ceil(1.1);    // Çıktı: 2
echo ceil(1.19);    // Çıktı: 2
echo ceil(1.5);    // Çıktı: 2
echo ceil(1.55);    // Çıktı: 2
echo ceil(1.9);    // Çıktı: 2
echo ceil(1.91);    // Çıktı: 2

echo round(1.11);    // Çıktı: 1
echo round(1.19);    // Çıktı: 1
echo round(1.5);    // Çıktı: 2
echo round(1.55);    // Çıktı: 2
echo round(1.9);    // Çıktı: 2
echo round(1.91);    // Çıktı: 2

 

paylaş Paylaş
oylama yap Oyla

makale yorumları YORUMLAR

Bu makale için yorum yazılmamış