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

Type conversions not according to documentation #25

Closed
tethal opened this issue Oct 5, 2015 · 5 comments
Closed

Type conversions not according to documentation #25

tethal opened this issue Oct 5, 2015 · 5 comments

Comments

@tethal
Copy link
Contributor

tethal commented Oct 5, 2015

According to documentation, strings should be converted to numbers, but they seem to be converted to floats:

printf("%y\n", 4 / 2.2n);         # gives 1.818181818181818181818181818181818181814
printf("%y\n", 4 / "2.2");        # gives 1.81818182

(Tested with version 0.8.12, git hash: 2ee5c95)

@tethal tethal added the bug label Oct 5, 2015
@davidnich
Copy link
Contributor

let's fix the docs and generally support implicit conversions to a float instead of a number since it's more efficient and let users use numbers only explicitly since they're expensive

@tethal
Copy link
Contributor Author

tethal commented Dec 29, 2015

These should be explained somehow as well:

$ qore -n -X 'number(0.1)'
0.10000000000000001
$ qore -n -X '0.1 + 1e20n'
100000000000000000000.1000000000000000099
$ qore -n -X '0.1 + 1e30n'
1000000000000000000000000000000.1
$ qore -n -X '0.1 + 1e40n'
10000000000000000000000000000000000000000.100000000000000010003
$ qore -n -X '0.1 + 1e100n'
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.100000000000000010000000000000000000000085004940396

@gamato
Copy link
Contributor

gamato commented Dec 29, 2015

And perhaps it should be noted in docs even more that simple use cases like exp2(16) will actually execute number exp2(number) version of the function.

@davidnich
Copy link
Contributor

@tethal the issue with the excess output is a result of the rounding heuristic - maybe we should try to improve the algorithm; current it requires 9 or 15 consecutive 0s or 9s before it decides that the rest is noise...

@davidnich davidnich added the fixed label Feb 1, 2019
@davidnich
Copy link
Contributor

docs have been corrected

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

No branches or pull requests

3 participants