MetalUp / Express

Integrated Learning Environment
1 stars 0 forks source link

VB - infinity displayed as '8' #176

Closed richardpawson closed 1 year ago

richardpawson commented 1 year ago

I have defined in the HiddenCodefile a variable x with the value 3.2.

I can access this in the Expression pane, OK, and it shows its value, and use it in expressions e.g. 1/x

I then tried 1/(x-x) because I wanted to produce the runtime division by zero error (as distinct from the compile time 'division by constant zero' that you get from e.g. 1/0)

Astonishingly, 1/(x-x) evaluated to 8 !

I then tried the same expression in VS and realised that there it returns the infinity symbol. Did it always do this? Is the runtime division by zero error just in my imagination?

Either way, this is what VS does now. Perhaps in our set up, something somewhere has decided that since that symbol looks like an 8 on its side, it should be best rendered as an '8'.

Looking into this a little, the 8 seems to be coming back from the server in StdOut so the conversion is happening server side.

See also https://stackoverflow.com/questions/40907417/why-is-infinity-printed-as-8-in-the-windows-10-console#:~:text=The%208%20symbol%20occurs%20when,%22windows%2D1252%22%20encoding.

scascarini commented 1 year ago

I have failed to get this to work on azure (it works locally) with a 'systemic' fix.

The workaround is to add

Console.OutputEncoding = Encoding.UTF8;

To the C# and VB wrapper files before the call to Console.WriteLine

richardpawson commented 1 year ago

Completed