Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
soulofmischief opened this issue Jan 29, 2021 · 4 comments
Open

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

soulofmischief opened this issue Jan 29, 2021 · 4 comments

Comments

@soulofmischief
Copy link
Contributor

soulofmischief commented Jan 29, 2021

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.

@soulofmischief soulofmischief changed the title "sprintf" returns "f" for double instead of value "sprintf %f" returns "f" for double instead of value Jan 29, 2021
@benswift
Copy link
Collaborator

benswift commented Feb 2, 2021

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
Copy link
Collaborator

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
Copy link
Contributor Author

No worries, I'm making do for now.

@soulofmischief
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants