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

  • Home
  • SEARCH
  • 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 7860635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:22:07+00:00 2026-06-02T22:22:07+00:00

i read the ecmascript 9.8.1 section ToString Applied to the Number Type, but i

  • 0

i read the ecmascript 9.8.1 section ToString Applied to the Number Type,
but i don’t know what it means.

The operator ToString converts a number m to string format as follows:

  1. If m is NaN, return the string “NaN”.

  2. If m is +0 or -0, return the string “0”.

  3. If m is less than zero, return the string concatenation of the string “-” and ToString(-m).

  4. If m is infinity, return the string “Infinity”.

  5. Otherwise, let n, k, and s be integers such that k >= 1, 10k-1<= s <10k, the number value for s * 10n-k is m, and k is as small as
    possible. Note that k is the number of digits in the decimal
    representation of s, that s is not divisible by 10, and that the least
    significant digit of s is not necessarily uniquely determined by these
    criteria.

  6. If k <= n <= 21, return the string consisting of the k digits of the decimal representation of s (in order, with no leading zeroes),
    followed by n k occurrences of the character ‘0’.

  7. If 0 < n <= 21, return the string consisting of the most significant n digits of the decimal representation of s, followed by a
    decimal point ‘. ‘, followed by the remaining k-n digits of the
    decimal representation of s.

  8. If -6 < n <= 0, return the string consisting of the character ‘0’, followed by a decimal point ‘. ‘, followed by -n occurrences of the
    character ‘0’, followed by the k digits of the decimal representation
    of s.

  9. Otherwise, if k = 1, return the string consisting of the single digit of s, followed by lowercase character ‘e’, followed by a plus
    sign ‘+ ‘ or minus sign ‘-‘ according to whether n-1 is positive or
    negative, followed by the decimal representation of the integer
    abs(n-1) (with no leading zeros).

  10. Return the string consisting of the most significant digit of the decimal representation of s, followed by a decimal point ‘. ‘,
    followed by the remaining k-1 digits of the decimal representation of
    s, followed by the lowercase character ‘e’, followed by a plus sign ‘+
    ‘ or minus sign ‘-‘ according to whether n-1 is positive or negative,
    followed by the decimal representation of the integer abs(n-1) (with
    no leading zeros).

can somebody explain the algorithm to me or give me a blog about the ToString Applied to the Number Type?

  • 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-02T22:22:09+00:00Added an answer on June 2, 2026 at 10:22 pm

    The specification is made for developers of JavaScript engines. It describes details of the engines’ internals, that may not be relevant to JS developers.

    Particularly, the ToString operation can not be called directly from JS. You can get almost the same effect by this function:

      function ToString(input) {
          return '' + input;
      }
    

    Now section 9.8.1 simply describes what should happen when a number is passed into this function.

    Points 5. to 10. make sure that very large numbers or numbers with many decimal places are stringified to scientific notation like so:

    ToString(100000000000000000000) // "100000000000000000000"
    ToString(10000000000000000000000) // "1e+22"
    ToString(.000003001) // ".000003001"
    ToString(.0000003001) // "3.001e-7"
    ToString(100000000.00000003001) // "100000000.00000003"
    ToString(1000000000.00000003001) // "1000000000"
    

    As for 5.: It can be deduced that

    If m is an integer, n is the number of digits of m. s is the integer that results from stripping all trailing zeroes, and k is the number of digits in s.

    So for example

    • m = 100000000000000000000 would yield s = 1, k = 1, n = 21, thus point 6. returns "100000000000000000000"
    • m = 10000000000000000000000 means s = 1, k = 1, n = 23, thus point 9. returns "1e+22"
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

read is defined in the Prelude as read :: (Read a) => String ->
(read) takes in a string from stdin, parses it as an s-expression, and returns
Read some other things on here re: this similar problem but am not sure
I read a string from a file with shell script variables, and want to
I read a lot of Q&As here but failed to find a working solution.
NOTE: As per ECMAScript5.1, section 15.1.1.3 , window.undefined is read-only. Modern browsers implement this
Read about the z-index issue and tried anything, but just can't seem to fix
Read a few things online and here but am now confused. What I want
I read both of the links below http://en.wikipedia.org/wiki/ECMAScript What is the difference between JavaScript
Read the old content into $content , then write $string . $content back into

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.