Converts a string to a float, in order to support negative values.

@access public
@author Jehan Bihin, <jehan.bihin@tudor.lu>
@param  string value
@return float
498023
public static function parseFloat($value)
    {
        $returnValue = (float) 0.0;

        $returnValue = str_replace(',', '.', $value);
        $returnValue = preg_replace('/[^\-\d.]/', '', $returnValue);

        return (float) $returnValue;
    }
1202870
public static function toFloat($value)
    {
        if (!static::is($value)) {
            throw new \InvalidArgumentException(
                "The \$value parameter must be numeric (or string representing a big number)."
            );
        }

        if (is_int($value) || is_float($value)) {
            return (float)$value;
        } else {
            return ((Str::contains($value, '.')) ? $value : $value . '.0');
        }
    }
257927
private function convertInt($value)
    {
        if (!is_numeric($value)) {
            return $value;
        }

        if ((string) (int) $value !== (string) $value) {
            return $value;
        }

        return (int) $value;
    }
1359718
public function convert($value)
    {
        if (!is_scalar($value)) {
            return false;
        }

        if (is_string($value)) {
            return $value;
        }

        if (is_float($value)) {
            return sprintf('float_%.4f', $value);
        }

        $prefix = '';

        if (!is_bool($value)) {
            $prefix = gettype($value) . '_';
        }

        
        return $prefix . var_export($value, true);
    }
491154
public static String writeFloat(Float value) {
		if (value==null) return null;
		
		return Float.toString(value);			
	}
1363663
public static function convert($value, $options = self::VAR_STRING)
    {
        $options = (int)$options;

        if ($options & self::VAR_STRING && !empty($value)) {
            return trim(Filter::stripQuotes($value));
        }

        if ($options & self::VAR_FLOAT) {
            return Filter::float($value, 12);
        }

        if ($options & self::VAR_INT) {
            return Filter::int($value);
        }

        if ($options & self::VAR_BOOL || $options & self::VAR_NULL) {
            if (null === $value || 'null' === strtolower(trim($value))) {
                return null;
            }

            return Filter::bool($value);
        }

        return (string)$value;
    }
1300427
public static function float(&$value=0, bool $flatten=false) {
		// Short circuit.
		if (\is_float($value)) {
			return;
		}

		if (! $flatten && \is_array($value)) {
			foreach ($value as $k=>$v) {
				static::float($value[$k]);
			}
		}
		else {
			static::number($value, true);
			try {
				$value = (float) $value;
			} catch (\Throwable $e) {
				$value = 0.0;
			}
		}
	}
1281498
public static function parseSize($value)
    {
        $l = substr($value, -1);

        if ($l === 'b' || $l === 'B') {
            return ((int)substr($value, 0, -1));
        }

        if ($l === 'k') {
            return ((int)substr($value, 0, -1) * 1000);
        }

        if ($l === 'K') {
            return ((int)substr($value, 0, -1) * 1024);
        }

        if ($l === 'm') {
            return ((int)substr($value, 0, -1) * 1000 * 1000);
        }

        if ($l === 'M') {
            return ((int)substr($value, 0, -1) * 1024 * 1024);
        }

        if ($l === 'g') {
            return ((int)substr($value, 0, -1) * 1000 * 1000 * 1000);
        }

        if ($l === 'G') {
            return ((int)substr($value, 0, -1) * 1024 * 1024 * 1024);
        }

        return (int)$value;
    }
365655
private function fixValue(string $value)
    {
        if ('' === $value) {
            return null;
        }

        if ('true' === $value) {
            return true;
        }

        if ('false' === $value) {
            return false;
        }

        if (is_numeric($value) && '0' !== $value[0]) {
            if ((string) (int) $value === $value) {
                return (int) $value;
            }

            return (float) $value;
        }

        return $value;
    }
636060
function Check($value)
    {
        $floatValue = 0.0;
        if (!GlobalNumberParser::TryParse($value, $floatValue)) {
            $this->error = self::NotParsed;
        }
        else {
            if (!$this->CheckMin($floatValue)) {
                 $this->error = self::ExceedsMin; 
            } else if (!$this->CheckMax($floatValue)) {
                $this->error = self::ExceedsMax;
            }
        }
        return $this->error == '';
    }
100045
def __float(value):
    ''''''
    valid, _value = False, value
    try:
        _value = float(value)
        valid = True
    except ValueError:
        pass
    return (valid, _value, 'float')
234871
protected function castString(string $value)
    {
        $val = trim($value);

        if (!is_numeric($val) && $val !== '') {
            return $this->dontCast($value);
        }

        $type = strpos($this->type, '|') !== false ? (strpos($val, '.') !== false ? 'float' : 'integer') : $this->type;
        settype($val, $type);

        return $val;
    }
1245156
def decimal_from_string(value)
      Float(value)
      BigDecimal(value, digits)
    rescue ArgumentError
      raise InvalidValueError, "Given value: #{value.inspect}"
    end
1099469
public static function convertToBytes(string $value): int
    {
        $units = "BKMGT";
        $unit = preg_replace("/[^$units]/i", "", $value);
        $value = floatval($value);
        if ($unit) {
            $value *= pow(1024, stripos($units, $unit[0]));
        }

        return (int) $value;
    }
585314
private function getValueAsString($value): string
    {
        if (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        if (is_float($value)) {
            $value = (string) $value;
            if (false === strpos($value, '.')) {
                $value .= '.0';
            }

            return $value;
        }

        if (is_int($value)) {
            return (string) $value;
        }

        throw new \InvalidArgumentException(sprintf('Unsupported data type: %s', gettype($value)));
    }
799220
public function displayValue( $value )
    {
        return $this->view->numberFormat(
            (float) $value,
            NumberFormatter::DECIMAL,
            NumberFormatter::TYPE_DOUBLE
        );
    }
415594
private function convertValue($value, $type){

        switch($type){
            case "is_numeric":
                $value = floatval($value);
                break;
            case "is_float":
                $value = floatval($value);
                break;
            case "is_string":
                $value = strval($value);
                break;
            default:
                $value = strval($value);
        }

        return $value;
    }