How to use parseFloat In Javascript
The parseFloat in JavaScript is a function used to convert a string to a floating-point number. It parses the input string, extracting and returning the numeric portion.
Syntax:
parseFloat(string);
Example: The below example uses parseFloat to perform String to Long Conversion.
let str = "12345678901234567890";
let res = parseFloat(str);
console.log(res);
Output
12345678901234567000
JavaScript Program for String to Long Conversion
In JavaScript, there is no specific data type called “Long”, but it uses the “Number” to represent the integer values. We can indirectly convert the String to Long by converting them to Number.
There are several approaches in Javascript to convert strings to long which are as follows:
Table of Content
- Using parseInt
- Using Number
- Using parseFloat
- Using BigInt
- Using Unary Plus (+)