Differences between IE and Firefox from a function

Source: Internet
Author: User
Recently, standardized web development has caught a cold, so fixfox is always used as a browser. However, since the system we are working on does not support non-ie browsers at all, we have to use IE during development, write some small tests Program I used Firefox, and the functions I made yesterday were rounded down. So I thought of the tofixed () function. I wrote a simple test program and tested it under fixfox. < Script Language = " Javascript " >
  Function Test ()
{
Alert ( 20.365 . Tofixed ( 2 ));
Alert ( 20.364 . Tofixed ( 2 ));
Alert ( 20.366 . Tofixed ( 2 ));

Alert ( 20.355 . Tofixed ( 2 ));
Alert ( 20.354 . Tofixed ( 2 ));
Alert ( 20.356 . Tofixed ( 2 ));

}

</ Script >
< Body onload = " Test (); " >

In fixfox, 20.36, 20.36, 20.37, 20.36, 20.35, 20.36
Obviously, this is the same as the round method in C #. It adopts the banker's rounding method, "four homes, six homes, five get even ".
I have long heard of the differences between the parsing of Javascript in IE and Firefox. So I started to test it in IE before, and the results are really different.
In IE, 20.37, 20.36, 20.37, 20.36, 20.35, 20.36, are displayed in sequence.
Obviously, ie is rounded down.Algorithm.
Microsoft is really weird. Why don't we leave it alone.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.