locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
14 lines (13 loc) • 432 B
JavaScript
import { _php_cast_int as __php_cast_int } from "./_php_cast_int.js";
export function _php_cast_float(value) {
// original by: Rafał Kukawski
if (typeof value === 'number') {
return value;
}
if (typeof value === 'string') {
return parseFloat(value) || 0;
}
// PHP docs state, that for types other than string
// conversion is {input type}->int->float
return __php_cast_int(value);
}