Title: wp_tinycolor_bound01
Published: August 8, 2023
Last modified: May 20, 2026

---

# wp_tinycolor_bound01( mixed $n, int $max ): float

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#wp--skip-link--target)

This function has been deprecated since 6.3.0.

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Takes input from [0, n] and returns it as [0, 1].

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#description)󠁿

Direct port of TinyColor’s function, lightly simplified to maintain consistency 
with TinyColor.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#parameters)󠁿

 `$n`mixedrequired

Number of unknown type.

`$max`intrequired

Upper value of the range to bound to.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#return)󠁿

 float Value in the range [0, 1].

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#source)󠁿

    ```php
    function wp_tinycolor_bound01( $n, $max ) {
    	_deprecated_function( __FUNCTION__, '6.3.0' );
    	if ( 'string' === gettype( $n ) && str_contains( $n, '.' ) && 1 === (float) $n ) {
    		$n = '100%';
    	}

    	$n = min( $max, max( 0, (float) $n ) );

    	// Automatically convert percentage into number.
    	if ( 'string' === gettype( $n ) && str_contains( $n, '%' ) ) {
    		$n = (int) ( $n * $max ) / 100;
    	}

    	// Handle floating point rounding errors.
    	if ( ( abs( $n - $max ) < 0.000001 ) ) {
    		return 1.0;
    	}

    	// Convert into [0, 1] range if it isn't already.
    	return ( $n % $max ) / (float) $max;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/deprecated.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/deprecated.php#L4829)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/deprecated.php#L4829-L4849)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#related)󠁿

| Uses | Description | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  |

| Used by | Description | 
| [wp_tinycolor_rgb_to_rgb()](https://developer.wordpress.org/reference/functions/wp_tinycolor_rgb_to_rgb/)`wp-includes/deprecated.php` |

Rounds and converts values of an RGB object.

  | 
| [wp_tinycolor_hsl_to_rgb()](https://developer.wordpress.org/reference/functions/wp_tinycolor_hsl_to_rgb/)`wp-includes/deprecated.php` |

Converts an HSL object to an RGB object with converted and rounded values.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_tinycolor_bound01/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Deprecated.  | 
| [5.8.0](https://developer.wordpress.org/reference/since/5.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_tinycolor_bound01%2F)
before being able to contribute a note or feedback.