# imagify/1.3.5.1/inc/functions/formatting.php

Imagify Image Optimization: Optimize Images | Compress &amp; Convert to WebP/AVIF, version 1.3.5.1. 31 lines.

- Page: https://pluginprobe.com/plugins/imagify/1.3.5.1/code/inc/functions/formatting.php
- Raw: https://pluginprobe.com/plugins/imagify/1.3.5.1/raw/inc/functions/formatting.php
- Modified: 2016-01-27T15:07:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/imagify/1.3.5.1/code/inc/functions/formatting.php#L10-L20`.

```php
<?php 
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );

/**
 * Round UP to nearest half integer
 *
 * @since 1.0
 * @source http://stackoverflow.com/a/13526408
 *
 * @param  int $number  The number to round up
 * @return int $number  The formatted number
 */
function imagify_round_half_five( $number ) {
    $number = strval( $number );
    $number = explode( '.', $number );
      
    if ( ! isset( $number[1] ) ) {
	    return $number[0];
    }
    
    $decimal = floatval( '0.' . substr( $number[1], 0 , 2 ) ); // cut only 2 number
    if ( $decimal > 0 ) {
        if( $decimal <= 0.5 ) {
            return floatval( $number[0] ) + 0.5;
        } elseif ( $decimal > 0.5 && $decimal <= 0.99 ) {
            return floatval( $number[0]) + 1;
        }
    } else {
        return floatval( $number );
    }
}
```
