I encountered an interesting problem while doing business recently:
In order to calculate money accurately, the server converts money into units (1 yuan = 100)
You need to convert it to money format at the front end 159 => 1.59 yuan
After looking at the project, the implementation method is to use tofixed, but there are bugs.
Require
159 -> 1.59元 1500 -> 15.00 元 88 -> 0.88元 8 -> 0.08元
In addition, sometimes the display format is (yuan is larger, minutes is smaller)
A simple example is as follows:
Simple test case: