digego / extempore

A cyber-physical programming environment
1.41k stars 127 forks source link

"sprintf %f" returns "f" for double instead of value #396

Open soulofmischief opened 3 years ago

soulofmischief commented 3 years ago

Environment: 64-bit Windows 10 Built from latest Extempore master

Problem: toString is not working for doubles or floats. It uses sprintf %f under the hood. Tinkering with sprintf directly reveals that doubles and floats return f instead of 1.0.

Example: (toString 1.0) returns 'f' instead of '1.0'

It seems sprintf directly binds to a C lib in llvmti.xtm? I'm not sure. I am not familiar enough with LLVM to understand how to venture beyond this point without guidance.

benswift commented 3 years ago

Hmm, ok, thanks. It's true that most of those stdio things are passed straight through to LLVM, so I'll look into it from there.

benswift commented 3 years ago

Sorry I haven't had a chance to look at this yet - I'm just currently 'between Windows boxes' and don't have an easy way to test. Will get back on it asap.

soulofmischief commented 3 years ago

No worries, I'm making do for now.

soulofmischief commented 3 years ago

After being frustrated with the existing JSON parsing bindings I wrote bindings for cJSON and wrote an example extempore program which uses curl and cJSON to pull hourly forecast data from the National Weather Service API and create generative music using the results.

I am planning to merge this upstream but bindings using toString on floats/doubles are broken and I'd like to incorporate them and remove my hacky macros.