Fix floating-point literal emit to be locale-independent. (#315)
Fix floating-point literal emit to be locale-independent. (#315)

There was a bug that arose in the context of Falcor, because:

- Slang uses `sprintf` to format floating-point values when outputting HLSL/GLSL source

- Falcor (or a library it uses) does the equivalent of `setlocale(LC_ALL, "")` to set the global locale for the process based on the user's environment variables

This led to a floating-point literal of `0.5` getting printed as `0,5f`, with a comma for the decimal point. This then gets consumed by `glslang` which (luckily for us) complains that `5f` is not a valid floating-point literal in their language (since it has neither decimal point nor exponent).

The most expedient fix in this case was to switch from using C `sprintf` for formatting floating-point numbers over to using the C++ `<stdio>` implementation, which allows the locale to be set per-stream so that we don't have to rely on (or potentially disrupt) the global locale set by an application using Slang.

Longer term if we have the time/resources to do the Right Thing, it would be best to implement our own printing logic for floating-point numbers, since we would eventually need/want to support arbitrary-precision numbers for literals.
shader-slang/slang,shader-slang/slang,csyonghe/slang,shader-slang/slang,csyonghe/slang,csyonghe/slang