Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Liczby całkowite :(
Setesh
post
Post #1





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 2.10.2006
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


Mam problem...

Jak to wyrazić za pomocą liczb całkowitych ? (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

  1. <?php
  2. $files=17;
  3.  $ile = $files / 3;
  4.  echo 'Ile = '.$ile.'<br>';
  5.  $test = $ile * 3;
  6.  echo 'test = '.$test.'<br>';
  7.  if($test < $files) $ile++;
  8.  echo 'ile = '.$ile.'<br>';
  9. ?>


Kto wie jak się zaokrągla w dół w php ? (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

Ten post edytował Setesh 30.04.2007, 19:26:47
Go to the top of the page
+Quote Post
kornel-php
post
Post #2





Grupa: Zarejestrowani
Postów: 210
Pomógł: 20
Dołączył: 7.07.2006
Skąd: Krotoszyn

Ostrzeżenie: (0%)
-----


Zaokrąglanie matematyczne: round()" title="Zobacz w manualu PHP" target="_manual
Zaokrąglanie w górę: ceil()" title="Zobacz w manualu PHP" target="_manual
Zaokrąglanie w dół: floor()" title="Zobacz w manualu PHP" target="_manual
Go to the top of the page
+Quote Post
Setesh
post
Post #3





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 2.10.2006
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


Poradziłem sobie w trochę inny sposób ale... ważne że działa (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

code : (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

  1. <?php
  2. $ile = (int) ($files / 3);
  3.  echo 'Ile = '.$ile.'<br>';
  4.  $test = (int) ($ile * 3);
  5.  echo 'test = '.$test.'<br>';
  6.  if($test < $files) $ile++;
  7.  echo 'ile = '.$ile.'<br>';
  8.  $test = (int) $ile * 3;
  9.  echo 'test = '.$test.'<br>';
  10. ?>


(IMG:http://forum.php.pl/style_emoticons/default/cool.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 23:51