Hoa central
Odd.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Realdom;
38 
39 use Hoa\Math;
40 
49 class Odd extends Realdom
50 {
56  const NAME = 'odd';
57 
63  protected $_arguments = [
64  'Integer number'
65  ];
66 
67 
68 
75  protected function _predicate($q)
76  {
77  return $this['number']->predicate($q) && ($q & 1) == 1;
78  }
79 
86  protected function _sample(Math\Sampler $sampler)
87  {
88  $q = $this['number']->sample($sampler);
89 
90  if (($q & 1) == 0) {
91  --$q;
92  }
93 
94  return $q;
95  }
96 }
_sample(Math\Sampler $sampler)
Definition: Odd.php:86
const NAME
Definition: Odd.php:56
_predicate($q)
Definition: Odd.php:75