|
@@ 181-198 (lines=18) @@
|
| 178 |
|
* @throws IntegrityConstraint
|
| 179 |
|
* @return NumberInterface
|
| 180 |
|
*/
|
| 181 |
|
public static function makePi($precision = null)
|
| 182 |
|
{
|
| 183 |
|
|
| 184 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 185 |
|
throw new IntegrityConstraint(
|
| 186 |
|
'$precision must be between 1 and 100 inclusive',
|
| 187 |
|
'Provide a precision within range',
|
| 188 |
|
'The PI constant cannot have a precision higher than the constant stored (100)'
|
| 189 |
|
);
|
| 190 |
|
}
|
| 191 |
|
|
| 192 |
|
if (!is_null($precision)) {
|
| 193 |
|
return self::make(self::IMMUTABLE, self::PI, $precision)->roundToPrecision($precision);
|
| 194 |
|
} else {
|
| 195 |
|
return self::make(self::IMMUTABLE, self::PI, 100);
|
| 196 |
|
}
|
| 197 |
|
|
| 198 |
|
}
|
| 199 |
|
|
| 200 |
|
/**
|
| 201 |
|
* @param int|null $precision
|
|
@@ 206-221 (lines=16) @@
|
| 203 |
|
* @throws IntegrityConstraint
|
| 204 |
|
* @return NumberInterface
|
| 205 |
|
*/
|
| 206 |
|
public static function makeTau($precision = null)
|
| 207 |
|
{
|
| 208 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 209 |
|
throw new IntegrityConstraint(
|
| 210 |
|
'$precision must be between 1 and 100 inclusive',
|
| 211 |
|
'Provide a precision within range',
|
| 212 |
|
'The TAU constant cannot have a precision higher than the constant stored (100)'
|
| 213 |
|
);
|
| 214 |
|
}
|
| 215 |
|
|
| 216 |
|
if (!is_null($precision)) {
|
| 217 |
|
return self::make(self::IMMUTABLE, self::TAU, $precision)->roundToPrecision($precision);
|
| 218 |
|
} else {
|
| 219 |
|
return self::make(self::IMMUTABLE, self::TAU, 100);
|
| 220 |
|
}
|
| 221 |
|
}
|
| 222 |
|
|
| 223 |
|
/**
|
| 224 |
|
* @param int|null $precision
|
|
@@ 239-256 (lines=18) @@
|
| 236 |
|
* @throws IntegrityConstraint
|
| 237 |
|
* @return NumberInterface
|
| 238 |
|
*/
|
| 239 |
|
public static function makeE($precision = null)
|
| 240 |
|
{
|
| 241 |
|
|
| 242 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 243 |
|
throw new IntegrityConstraint(
|
| 244 |
|
'$precision must be between 1 and 100 inclusive',
|
| 245 |
|
'Provide a precision within range',
|
| 246 |
|
'The E constant cannot have a precision higher than the constant stored (100)'
|
| 247 |
|
);
|
| 248 |
|
}
|
| 249 |
|
|
| 250 |
|
if (!is_null($precision)) {
|
| 251 |
|
return self::make(self::IMMUTABLE, self::E, $precision)->roundToPrecision($precision);
|
| 252 |
|
} else {
|
| 253 |
|
return self::make(self::IMMUTABLE, self::E, 100);
|
| 254 |
|
}
|
| 255 |
|
|
| 256 |
|
}
|
| 257 |
|
|
| 258 |
|
/**
|
| 259 |
|
* @param int|null $precision
|
|
@@ 264-281 (lines=18) @@
|
| 261 |
|
* @throws IntegrityConstraint
|
| 262 |
|
* @return NumberInterface
|
| 263 |
|
*/
|
| 264 |
|
public static function makeGoldenRatio($precision = null)
|
| 265 |
|
{
|
| 266 |
|
|
| 267 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 268 |
|
throw new IntegrityConstraint(
|
| 269 |
|
'$precision must be between 1 and 100 inclusive',
|
| 270 |
|
'Provide a precision within range',
|
| 271 |
|
'The Golden Ratio constant cannot have a precision higher than the constant stored (100)'
|
| 272 |
|
);
|
| 273 |
|
}
|
| 274 |
|
|
| 275 |
|
if (!is_null($precision)) {
|
| 276 |
|
return self::make(self::IMMUTABLE, self::GOLDEN_RATIO, $precision)->roundToPrecision($precision);
|
| 277 |
|
} else {
|
| 278 |
|
return self::make(self::IMMUTABLE, self::GOLDEN_RATIO, 100);
|
| 279 |
|
}
|
| 280 |
|
|
| 281 |
|
}
|
| 282 |
|
|
| 283 |
|
/**
|
| 284 |
|
* @param int|null $precision
|
|
@@ 289-306 (lines=18) @@
|
| 286 |
|
* @throws IntegrityConstraint
|
| 287 |
|
* @return NumberInterface
|
| 288 |
|
*/
|
| 289 |
|
public static function makeNaturalLog10($precision = null)
|
| 290 |
|
{
|
| 291 |
|
|
| 292 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 293 |
|
throw new IntegrityConstraint(
|
| 294 |
|
'$precision must be between 1 and 100 inclusive',
|
| 295 |
|
'Provide a precision within range',
|
| 296 |
|
'The natural log of 10 constant cannot have a precision higher than the constant stored (100)'
|
| 297 |
|
);
|
| 298 |
|
}
|
| 299 |
|
|
| 300 |
|
if (!is_null($precision)) {
|
| 301 |
|
return self::make(self::IMMUTABLE, self::LN_10, $precision)->roundToPrecision($precision);
|
| 302 |
|
} else {
|
| 303 |
|
return self::make(self::IMMUTABLE, self::LN_10, 100);
|
| 304 |
|
}
|
| 305 |
|
|
| 306 |
|
}
|
| 307 |
|
|
| 308 |
|
/**
|
| 309 |
|
* @return ImmutableNumber
|