Class Number

Methods summary

public number
# flexround( string $value )

Rounds the value only out to its most significant digit.

public boolean
# isNumber( $string )

Checks if a given string is valid representation of a number in the current locale.

public boolean
# isInteger( $string )

Checks if a given string is valid representation of an integer in the current locale.

public string
# format( number $number, integer|null $precision = null )

Format a number with grouped thousands and localized decimal point/thousands separator.

public null|number
# unformat( string $string, boolean $trim = true, integer|null $precision = null )

Parses a localized number representation and returns the number (or null if $string is not a valid number representation).

public string|mixed
# formatSize( number $size, string $forceUnit = '' )

Formats a size (measured in bytes, KB, MB, ...).

public integer|string
# getBytes( $val )

Nice and elegant function for converting memory. Thanks to @lightness races in orbit on Stackoverflow.