Fix compiling edge-cases
This commit is contained in:
parent
bd2307f782
commit
4a6a25a081
2 changed files with 21 additions and 9 deletions
|
|
@ -3,5 +3,13 @@
|
|||
*
|
||||
* Returns non-numbers as is.
|
||||
*/
|
||||
export const numberToGlslFloat = (value: number | string): string =>
|
||||
Number.isInteger(value) ? `${value}.0` : value.toString();
|
||||
export const numberToGlslFloat = (value: number | string): string => {
|
||||
if (typeof value !== 'number') {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
const asString = value.toString();
|
||||
|
||||
// Very large integers stringify in exponent notation (1e21)
|
||||
return Number.isInteger(value) && !asString.includes('e') ? `${asString}.0` : asString;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue