ASP.NET Session ID Reuse; VBScript Rounding Errors

GeekSpeak comments edit

Catching up on the morning news and whatnot I came across two different and interesting issues.

The first is a new KB article over at Microsoft: How and Why Session IDs are Reused in ASP.NET. Describes how the session ID is reused across applications on a server but the session instance is local to the application. Also describes what to do if you don’t want to reuse the session ID for your application.

The second issue is something I ran across this weekend. I was using a calculator program and one of the operations I entered (in the series) was 5.35 - 5.45. The answer I got back was -0.100000000000001: just a bit off from what I was expecting. I tried it again, and the same answer came back.

I ended up contacting the author of the program and he uses the Windows Script Host to perform calculations, so I wrote a quick test VBScript:

Dim myvar
myvar = 5.35 - 5.45
WScript.Echo myvar

Turns out the answer is still -0.100000000000001. I did a quick search on this and Eric Lippert explains why it’s happening. Long story short - rounding errors due to the base 2 nature of the computer. I understand the answer, but I’m not sure I like it. Makes me wonder if computers shouldn’t have been base 10 to begin with. Heh.