|
@@ 221-238 (lines=18) @@
|
| 218 |
|
* @throws IntegrityConstraint
|
| 219 |
|
* @return NumberInterface
|
| 220 |
|
*/
|
| 221 |
|
public static function makePi($precision = null)
|
| 222 |
|
{
|
| 223 |
|
|
| 224 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 225 |
|
throw new IntegrityConstraint(
|
| 226 |
|
'$precision must be between 1 and 100 inclusive',
|
| 227 |
|
'Provide a precision within range',
|
| 228 |
|
'The PI constant cannot have a precision higher than the constant stored (100)'
|
| 229 |
|
);
|
| 230 |
|
}
|
| 231 |
|
|
| 232 |
|
if (!is_null($precision)) {
|
| 233 |
|
return self::make(self::IMMUTABLE, self::PI, $precision)->roundToPrecision($precision);
|
| 234 |
|
} else {
|
| 235 |
|
return self::make(self::IMMUTABLE, self::PI, 100);
|
| 236 |
|
}
|
| 237 |
|
|
| 238 |
|
}
|
| 239 |
|
|
| 240 |
|
/**
|
| 241 |
|
* @param int|null $precision
|
|
@@ 246-261 (lines=16) @@
|
| 243 |
|
* @throws IntegrityConstraint
|
| 244 |
|
* @return NumberInterface
|
| 245 |
|
*/
|
| 246 |
|
public static function makeTau($precision = null)
|
| 247 |
|
{
|
| 248 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 249 |
|
throw new IntegrityConstraint(
|
| 250 |
|
'$precision must be between 1 and 100 inclusive',
|
| 251 |
|
'Provide a precision within range',
|
| 252 |
|
'The TAU constant cannot have a precision higher than the constant stored (100)'
|
| 253 |
|
);
|
| 254 |
|
}
|
| 255 |
|
|
| 256 |
|
if (!is_null($precision)) {
|
| 257 |
|
return self::make(self::IMMUTABLE, self::TAU, $precision)->roundToPrecision($precision);
|
| 258 |
|
} else {
|
| 259 |
|
return self::make(self::IMMUTABLE, self::TAU, 100);
|
| 260 |
|
}
|
| 261 |
|
}
|
| 262 |
|
|
| 263 |
|
/**
|
| 264 |
|
* @param int|null $precision
|
|
@@ 279-296 (lines=18) @@
|
| 276 |
|
* @throws IntegrityConstraint
|
| 277 |
|
* @return NumberInterface
|
| 278 |
|
*/
|
| 279 |
|
public static function makeE($precision = null)
|
| 280 |
|
{
|
| 281 |
|
|
| 282 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 283 |
|
throw new IntegrityConstraint(
|
| 284 |
|
'$precision must be between 1 and 100 inclusive',
|
| 285 |
|
'Provide a precision within range',
|
| 286 |
|
'The E constant cannot have a precision higher than the constant stored (100)'
|
| 287 |
|
);
|
| 288 |
|
}
|
| 289 |
|
|
| 290 |
|
if (!is_null($precision)) {
|
| 291 |
|
return self::make(self::IMMUTABLE, self::E, $precision)->roundToPrecision($precision);
|
| 292 |
|
} else {
|
| 293 |
|
return self::make(self::IMMUTABLE, self::E, 100);
|
| 294 |
|
}
|
| 295 |
|
|
| 296 |
|
}
|
| 297 |
|
|
| 298 |
|
/**
|
| 299 |
|
* @param int|null $precision
|
|
@@ 304-321 (lines=18) @@
|
| 301 |
|
* @throws IntegrityConstraint
|
| 302 |
|
* @return NumberInterface
|
| 303 |
|
*/
|
| 304 |
|
public static function makeGoldenRatio($precision = null)
|
| 305 |
|
{
|
| 306 |
|
|
| 307 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 308 |
|
throw new IntegrityConstraint(
|
| 309 |
|
'$precision must be between 1 and 100 inclusive',
|
| 310 |
|
'Provide a precision within range',
|
| 311 |
|
'The Golden Ratio constant cannot have a precision higher than the constant stored (100)'
|
| 312 |
|
);
|
| 313 |
|
}
|
| 314 |
|
|
| 315 |
|
if (!is_null($precision)) {
|
| 316 |
|
return self::make(self::IMMUTABLE, self::GOLDEN_RATIO, $precision)->roundToPrecision($precision);
|
| 317 |
|
} else {
|
| 318 |
|
return self::make(self::IMMUTABLE, self::GOLDEN_RATIO, 100);
|
| 319 |
|
}
|
| 320 |
|
|
| 321 |
|
}
|
| 322 |
|
|
| 323 |
|
/**
|
| 324 |
|
* @param int|null $precision
|
|
@@ 329-346 (lines=18) @@
|
| 326 |
|
* @throws IntegrityConstraint
|
| 327 |
|
* @return NumberInterface
|
| 328 |
|
*/
|
| 329 |
|
public static function makeNaturalLog10($precision = null)
|
| 330 |
|
{
|
| 331 |
|
|
| 332 |
|
if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
| 333 |
|
throw new IntegrityConstraint(
|
| 334 |
|
'$precision must be between 1 and 100 inclusive',
|
| 335 |
|
'Provide a precision within range',
|
| 336 |
|
'The natural log of 10 constant cannot have a precision higher than the constant stored (100)'
|
| 337 |
|
);
|
| 338 |
|
}
|
| 339 |
|
|
| 340 |
|
if (!is_null($precision)) {
|
| 341 |
|
return self::make(self::IMMUTABLE, self::LN_10, $precision)->roundToPrecision($precision);
|
| 342 |
|
} else {
|
| 343 |
|
return self::make(self::IMMUTABLE, self::LN_10, 100);
|
| 344 |
|
}
|
| 345 |
|
|
| 346 |
|
}
|
| 347 |
|
|
| 348 |
|
/**
|
| 349 |
|
* @return ImmutableNumber
|