3v4l.org

run code in 500+ PHP versions simultaneously
<?php $modes = [ "PHP_ROUND_HALF_UP" => PHP_ROUND_HALF_UP, "PHP_ROUND_HALF_DOWN" => PHP_ROUND_HALF_DOWN, "PHP_ROUND_HALF_EVEN" => PHP_ROUND_HALF_EVEN, "PHP_ROUND_HALF_ODD" => PHP_ROUND_HALF_ODD, ]; $numbers = [ 0.49999999999999991, 0.49999999999999992, 0.49999999999999993, 0.49999999999999994, 0.49999999999999995, 0.49999999999999996, 0.49999999999999997, 0.49999999999999998, 0.49999999999999999, 0.499999999999999999, // 0.50000000000000001, ]; $precisions = [0,1,5,10,16,17,18]; foreach ($modes as $modeKey => $mode) { echo "mode: $modeKey\n"; foreach ($precisions as $precision) { echo "\tprecision: $precision\n"; foreach ($numbers as $number) { var_dump($number, round($number, $precision, $mode)); //echo "\t\t" . // $number . // " => $result\n"; } echo "\n"; } }

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 33
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 33
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 31
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 28
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 31
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/A12Z0
function name:  (null)
number of ops:  35
compiled vars:  !0 = $modes, !1 = $numbers, !2 = $precisions, !3 = $mode, !4 = $modeKey, !5 = $precision, !6 = $number
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   10     1        ASSIGN                                                       !1, <array>
   23     2        ASSIGN                                                       !2, <array>
   25     3      > FE_RESET_R                                           $10     !0, ->33
          4    > > FE_FETCH_R                                           ~11     $10, !3, ->33
          5    >   ASSIGN                                                       !4, ~11
   26     6        ROPE_INIT                                         3  ~14     'mode%3A+'
          7        ROPE_ADD                                          1  ~14     ~14, !4
          8        ROPE_END                                          2  ~13     ~14, '%0A'
          9        ECHO                                                         ~13
   27    10      > FE_RESET_R                                           $16     !2, ->31
         11    > > FE_FETCH_R                                                   $16, !5, ->31
   28    12    >   ROPE_INIT                                         3  ~18     '%09precision%3A+'
         13        ROPE_ADD                                          1  ~18     ~18, !5
         14        ROPE_END                                          2  ~17     ~18, '%0A'
         15        ECHO                                                         ~17
   29    16      > FE_RESET_R                                           $20     !1, ->28
         17    > > FE_FETCH_R                                                   $20, !6, ->28
   30    18    >   INIT_FCALL                                                   'var_dump'
         19        SEND_VAR                                                     !6
         20        INIT_FCALL                                                   'round'
         21        SEND_VAR                                                     !6
         22        SEND_VAR                                                     !5
         23        SEND_VAR                                                     !3
         24        DO_ICALL                                             $21     
         25        SEND_VAR                                                     $21
         26        DO_ICALL                                                     
   29    27      > JMP                                                          ->17
         28    >   FE_FREE                                                      $20
   35    29        ECHO                                                         '%0A'
   27    30      > JMP                                                          ->11
         31    >   FE_FREE                                                      $16
   25    32      > JMP                                                          ->4
         33    >   FE_FREE                                                      $10
   37    34      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
115.78 ms | 504 KiB | 11 Q