public function MathfieldTestCase::randFloat in Math Field 7
Generate a random float between -1000 and 1000 with 2 decimal places.
2 calls to MathfieldTestCase::randFloat()
- MathfieldTestCase::createField in ./
mathfield.test - Create a number field and instance.
- MathfieldTokenTestCase::testMathfieldBasicTokens in ./
mathfield.test - Tests basic tokens in math expression fields.
File
- ./
mathfield.test, line 38 - Tests for mathfield.module.
Class
- MathfieldTestCase
- Base class for testing the mathfield module.
Code
public function randFloat($min = -1000, $max = 1000, $scale = 2) {
if ($scale < 1) {
return $this
->randInteger();
}
return mt_rand($min * 10 * $scale, $max * 10 * $scale) / (10 * $scale);
}