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

string() with weval-ed WExpr escape (\) some characters on arbitrary precision floating numbers with back quote #94

Open
gvanuxem opened this issue May 27, 2024 · 1 comment

Comments

@gvanuxem
Copy link

Here is an example session:

julia> set_GreedyEval(false)
false

julia> a=W`17.00000000000000000000000000000`
17.`30.230448921378276

julia> string(a)
"17.`30.230448921378276"

julia> W"Sin"(W"Sqrt"(a))
W`Sin[Sqrt[17.`30.230448921378276]]`

julia> string(W"Sin"(W"Sqrt"(a)))
"W`Sin[Sqrt[17.`30.230448921378276]]`"

julia> weval(W"Sin"(W"Sqrt"(a)))
-0.8313391791635062080451600446002018832298332563980832506813`30.091141206520284

julia> string(W"Sin"(W"Sqrt"(a)))
"W`Sin[Sqrt[17.\0`30.23044892137827]]`"

In the output of the last command, the 0 after the dot is escaped. In fact I have encountered this issue several times with back quote in "Real" numbers. Note that apparently this only happens if 'weval' was used on the WExpr. After, it seems no longer possible to restore the previous behaviour:

julia> string(W"Sin"(W"Sqrt"(a)))
"W`Sin[Sqrt[17.`30.230448921378276]]`"
@fremling
Copy link
Collaborator

Hi @gvanuxem,

Intersting bug, thanks for pointing it out to us. There is definitely something going wrong in the communication to the wolfram engine.

The example your give will eventually boil down to sending the weval call

julia> W"ToExpression"("17.0000000000000000000000000", W"StandardForm", W"Hold")
W`ToExpression["17.0000000000000000000000000", StandardForm, Hold]`

julia> weval(W"ToExpression"("17.0000000000000000000000000", W"StandardForm", W"Hold"))
W`Hold[17.`26.23044892137828]`

which is you can see gets destroyed somewhere on route. As a comparisson sneding the same statemnt directly in the mathematica entine (comand line or GUI) gives the correct return result.

In[41]:= ToExpression["17.0000000000000000000000000", StandardForm, Hold]       

Out[41]= Hold[17.000000000000000000000000]

I think we need to dig a bit deeper here and get back to you (ping @simonbyrne , any ideas?)

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