Open longchuan opened 2 weeks ago
3.8.4
windows 11
Long float dots had a bad format expect to have a float format ,not a scientific notation format.
No response
This method will solve the problem
public static getFloatString (strNum: number): string { let str = String(strNum); if (str.indexOf("e") !== -1) { let strArr = str.split("e"); let factor = strArr[0].split("."); let powNum = parseInt(strArr[1]); if (powNum < 0) { return "0" + "." + "0".repeat(-powNum - factor[0].length) + factor[0] + (factor.length === 2 ? factor[1] : ""); } else { if (factor.length === 2) { let dotNum = powNum - factor[1].length; if (dotNum < 0) { let spl = factor[1].slice(0, -dotNum); return factor[0] + spl[0] + "." + spl[1]; } else { return factor[0] + factor[1] + "0".repeat(dotNum - factor[0].length); } } else { return factor[0] + "0".repeat(powNum - factor[0].length); } } } else { return str; } }
@yufengctbu check the design doc or issue to see the purpose of why we're doing this.
Cocos Creator version
3.8.4
System information
windows 11
Issue description
Long float dots had a bad format expect to have a float format ,not a scientific notation format.
Relevant error log output
No response
Steps to reproduce
This method will solve the problem
Minimal reproduction project
No response