Skip to main content
Module

x/ddc_vim/deps.ts>fn.str2float

Dark deno-powered completion framework for neovim/Vim8
Go to Latest
function fn.str2float
import { fn } from "https://deno.land/x/ddc_vim@v2.3.0/deps.ts";
const { str2float } = fn;

Convert String {expr} to a Float. This mostly works the same as when using a floating point number in an expression, see |floating-point-format|. But it's a bit more permissive. E.g., "1e40" is accepted, while in an expression you need to write "1.0e40". The hexadecimal form "0x123" is also accepted, but not others, like binary or octal. Text after the number is silently ignored. The decimal point is always '.', no matter what the locale is set to. A comma ends the number: "12,345.67" is converted to 12.0. You can strip out thousands separators with |substitute()|: let f = str2float(substitute(text, ',', '', 'g')) Can also be used as a |method|: let f = text->substitute(',', '', 'g')->str2float() {only available when compiled with the |+float| feature}

Parameters

denops: Denops
expr: unknown

Returns

Promise<unknown>