Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8957753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:03:48+00:00 2026-06-15T15:03:48+00:00

I would like to convert a floating point variable to a string without losing

  • 0

I would like to convert a floating point variable to a string without losing any precision.

I.e. I would like the string to have the same information as my floating point variable contains, since I use the output for further processing (even if it means that the string will be very long and readable).

To put this more clearly, I would like to have functions for cyclic conversion

var dA = 323423.23423423e4;
var sA = toString(dA);
var dnA = toDouble(sA);

and I would like dnA and dA to be equal

Thanks

PS: Sources on the internet usually talk about how to round strings but I have not found information on exact representation. Also I am not interested in Arbitrary Precision calculations, I just need double precision floating point arithmetic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:03:49+00:00Added an answer on June 15, 2026 at 3:03 pm

    Let string arithmetic do the string conversion, and then use parseFloat to get it back to a float:

    var dA = 323423.23423423e4;
    var sA = dA + '';
    var dnA = parseFloat(sA);
    

    Here’s a fiddle to see it in action.

    Note: All JavaScript numbers are doubles, so you don’t need to draw a distinction between doubles and floats. Thus, the only place you’d need to worry about precision loss is in your first line. For example, if you did var dA = 987654321.0123456789 for your first line, it would be equivalent to var dA = 987654321.01234567, and dA would still equal dnA in the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to convert a string into a node. I have a method
I would like to convert a string of delimited dimension values into floating numbers.
I would like to convert the following string into an array/nested array and iterate
I would like to convert a Dictionary to a string array (or list) The
I'd like to a convert unix timestamp I have in a string (ex. 1277722499.82)
I would like to convert for example the string 98 to the integer 98.
I would like to convert this JavaScript code to python, i have not solide
I would like convert an array in D of the form: string[] arrayStr =
I would like to convert a GeoPoint to a screen point in order to
I would like to convert the string containing abc to a list of characters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.