public function trim($value)
    {
        $result = '';
        $value = (string) $value;
        if ($value !== '') {
            // Temporarily remove leadin sign
            $sign = $value[0];
            if ($sign === '-' || $sign === '+') {
                $value = substr($value, 1);
            } else {
                $sign = '';
            }
            if ($value !== '') {
                // Remove initial zeroes
                $value = ltrim($value, '0');
                if ($value === '' || $value[0] === '.') {
                    $value = '0' . $value;
                }
                if (strpos($value, '.') !== false) {
                    // Remove trailing zeroes after the dot
                    $value = rtrim(rtrim($value, '0'), '.');
                }
                $result = $sign . $value;
            }
        }

        return $result;
    }