3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /** * Returns N±(0~n/m) randomness * * @param $n int Base number * @param $m int Fraction of number to use for random/ * * @return float */ function addRandomToN($n, $m) { $plus = mt_rand(0,1); if ($plus) { return $n + (($n/$m) * rand0To1()); } return $n - (($n/$m) * rand0To1()); } function rand0To1() { return (float)rand()/(float)getrandmax(); } echo addRandomToN(5, 0.1);
Output for 7.1.0
1.3081672770475
Output for 7.0.14
-24.988859957079
Output for 7.0.12
14.804925606495
Output for 7.0.6
50.167888815127
Output for 7.0.5
40.121644421072
Output for 7.0.4
-5.6100850555161
Output for 7.0.3
48.671375463564
Output for 7.0.2
54.321396788266
Output for 7.0.1
20.018178902109
Output for 7.0.0
-6.0221666335231
Output for 5.6.28
48.410390030318
Output for 5.6.21
13.097175512508
Output for 5.6.20
-27.277961998376
Output for 5.6.19
-1.0510430047526
Output for 5.6.18
-41.05013660437
Output for 5.6.17
-31.212000244396
Output for 5.6.16
18.650367927575
Output for 5.6.15
5.845582085124
Output for 5.6.14
-39.136637236987
Output for 5.6.13
18.789037621482
Output for 5.6.12
32.444687172512
Output for 5.6.11
48.111076505441
Output for 5.6.10
-34.787320601655
Output for 5.6.9
36.85283515223
Output for 5.6.8
2.4392130027708
Output for 5.6.7
7.6178890152918
Output for 5.6.6
-25.47158209629
Output for 5.6.5
52.712960512244
Output for 5.6.4
-30.104775445119
Output for 5.6.3
8.7986999628128
Output for 5.6.2
36.017113957096
Output for 5.6.1
-9.4882466245854
Output for 5.6.0
-38.240168687534
Output for 5.5.35
-4.1173076113301
Output for 5.5.34
-30.122819447481
Output for 5.5.33
-5.9403305505125
Output for 5.5.32
-9.7729866741099
Output for 5.5.31
34.319353555012
Output for 5.5.30
0.14561064780951
Output for 5.5.29
13.258190102995
Output for 5.5.28
-42.902997512325
Output for 5.5.27
43.291319244677
Output for 5.5.26
16.154981218816
Output for 5.5.25
13.283562380021
Output for 5.5.24
-43.313370579068
Output for 5.5.23
50.392346473128
Output for 5.5.22
-6.0869300137679
Output for 5.5.21
-18.883619286997
Output for 5.5.20
47.897796953515
Output for 5.5.19
-38.098827890632
Output for 5.5.18
16.320326808524
Output for 5.5.16
29.76958743053
Output for 5.5.15
29.461219471163
Output for 5.5.14
-29.773301908175
Output for 5.5.13
-2.7303424280744
Output for 5.5.12
45.612691636483
Output for 5.5.11
-10.976828553703
Output for 5.5.10
53.886676714237
Output for 5.5.9
-18.743585135668
Output for 5.5.8
-3.3626514572476
Output for 5.5.7
-19.729515181263
Output for 5.5.6
-40.45476434075
Output for 5.5.5
6.5601980740019
Output for 5.5.4
-29.741842995743
Output for 5.5.3
41.2892256753
Output for 5.5.2
37.401507688873
Output for 5.5.1
38.215884577118
Output for 5.5.0
46.858043773965
Output for 5.4.45
-20.803734467273
Output for 5.4.44
-14.0362958559
Output for 5.4.43
-26.010555886203
Output for 5.4.42
-44.815601273354
Output for 5.4.41
51.908379042013
Output for 5.4.40
-38.073282038361
Output for 5.4.39
-8.400000014063
Output for 5.4.38
25.534305516879
Output for 5.4.37
-26.33644144113
Output for 5.4.36
-35.387174785317
Output for 5.4.35
41.779604566647
Output for 5.4.34
-8.6682511138116
Output for 5.4.32
18.308097568018
Output for 5.4.31
-6.247321013942
Output for 5.4.30
25.911528016865
Output for 5.4.29
47.211929518828
Output for 5.4.28
-44.524037306907
Output for 5.4.27
-12.61999119428
Output for 5.4.26
31.542627381414
Output for 5.4.25
6.6478671467155
Output for 5.4.24
-23.86138364154
Output for 5.4.23
-27.913434008562
Output for 5.4.22
36.693660668886
Output for 5.4.21
-8.3117685622125
Output for 5.4.20
49.647708881948
Output for 5.4.19
-31.384324839518
Output for 5.4.18
-17.434685319865
Output for 5.4.17
-25.832806313798
Output for 5.4.16
-25.856846147616
Output for 5.4.15
31.495826047145
Output for 5.4.14
46.789783021337
Output for 5.4.13
42.332824332329
Output for 5.4.12
50.287706793886
Output for 5.4.11
-18.582655994027
Output for 5.4.10
43.089302619029
Output for 5.4.9
28.521373315491
Output for 5.4.8
27.150611887756
Output for 5.4.7
-40.678659223802
Output for 5.4.6
29.178316362285
Output for 5.4.5
46.927757482942
Output for 5.4.4
-11.01811275632
Output for 5.4.3
-42.318290847968
Output for 5.4.2
-38.047089941356
Output for 5.4.1
-15.950682796981
Output for 5.4.0
15.727095282975
Output for 5.3.29
20.779170075329
Output for 5.3.28
-10.161765560117
Output for 5.3.27
20.349624080281
Output for 5.3.26
41.474853840878
Output for 5.3.25
32.050874255156
Output for 5.3.24
41.8768013487
Output for 5.3.23
3.880292055607
Output for 5.3.22
-25.948563213902
Output for 5.3.21
-10.792895814307
Output for 5.3.20
16.604253790157
Output for 5.3.19
-0.014247728983987
Output for 5.3.18
13.119708047304
Output for 5.3.17
19.85489782172
Output for 5.3.16
51.696434121903
Output for 5.3.15
26.900045718951
Output for 5.3.14
2.3262046451337
Output for 5.3.13
-23.121370323059
Output for 5.3.12
-2.7474911267625
Output for 5.3.11
51.86923210829
Output for 5.3.10
18.923861139418
Output for 5.3.9
35.883581997307
Output for 5.3.8
30.520206417665
Output for 5.3.7
31.782900596402
Output for 5.3.6
38.745743256875
Output for 5.3.5
-0.13966358506105
Output for 5.3.4
6.4399833052605
Output for 5.3.3
36.672070073742
Output for 5.3.2
9.5941234122003
Output for 5.3.1
52.051193144662
Output for 5.3.0
6.3465062954214
Output for 5.2.17
6.9738220618916
Output for 5.2.16
-15.71194344699
Output for 5.2.15
32.987374541344
Output for 5.2.14
-3.6891689611083
Output for 5.2.13
47.744659675632
Output for 5.2.12
5.3728318262719
Output for 5.2.11
53.171478089956
Output for 5.2.10
-32.328807142251
Output for 5.2.9
35.867299614878
Output for 5.2.8
40.850466292282
Output for 5.2.7
-35.723814508283
Output for 5.2.6
-29.732163061729
Output for 5.2.5
0.43675381943432
Output for 5.2.4
52.615734672926
Output for 5.2.3
18.018563558822
Output for 5.2.2
16.474703211093
Output for 5.2.1
41.33131246843
Output for 5.2.0
-43.678249935004
Output for 5.1.6
31.271354815118
Output for 5.1.5
-25.517730713132
Output for 5.1.4
32.849027224746
Output for 5.1.3
16.934399214543
Output for 5.1.2
-31.706822033369
Output for 5.1.1
6.9341254615849
Output for 5.1.0
37.002289584839
Output for 5.0.5
-22.833105147739
Output for 5.0.4
48.445892302993
Output for 5.0.3
37.835626384632
Output for 5.0.2
41.455245728816
Output for 5.0.1
-3.3303949601624
Output for 5.0.0
38.213287793665
Output for 4.4.9
-32.804884038775
Output for 4.4.8
-42.390176145076
Output for 4.4.7
12.630820040419
Output for 4.4.6
8.0359036303293
Output for 4.4.5
-21.298016019304
Output for 4.4.4
-31.457807610956
Output for 4.4.3
29.160675599315
Output for 4.4.2
-35.291280713999
Output for 4.4.1
-11.978676788033
Output for 4.4.0
50.874376406835
Output for 4.3.11
-37.636715291364
Output for 4.3.10
11.813920595131
Output for 4.3.9
54.012402165221
Output for 4.3.8
42.44552903224
Output for 4.3.7
42.512399622943
Output for 4.3.6
12.727514164395
Output for 4.3.5
2.6422366675186
Output for 4.3.4
37.584199510787
Output for 4.3.3
44.765224438051
Output for 4.3.2
52.562009677087
Output for 4.3.1
48.923409908974
Output for 4.3.0
44.957937523703