Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysterious number 18888888888888888 [closed]

Tags:

c#

.net

wpf

xaml

One of our testers, managed to set a slider bound variable to 18888888888888888 which can only take values between 1-100 normally. (I can observe it in view model which is saved to a xaml file.) What's special about this number?

Here are some details. The application has a slider, it is bound to an observable property in a view model. Normally, when application saves the workspace, this viewmodel is saved along using XamlServices.Save. My tester reported some awkward behaviour, the value of the slider showing -214 upon loading this project. I asked him to send me the file and the value in the saved xaml contains my mysterious number.

I know this is the result of a bug in my code, or some other library code. I will hopefully nail it down. However, normal "garbage" values cannot be like this. When I google, I see some non-programming related pages, which shows somehow this number was generated in history of internet (so it's not my cat's doing). In short, I am trying to figure out, how this number can be created in the first place, like when you see INT_MAX + 1, if you are experienced enough you can recognize it (-2137483648 anyone?).

like image 767
mentat Avatar asked Feb 09 '12 10:02

mentat


1 Answers

Assume the 1 at the beginning is a place holder - an error of displaying a double to string.

We've got 16 8's. The double type in C# has up to 16 bytes of precision. This may indicate that the slider display is trying to show some type of garbage double value of 8888888888888888, or 0x1000100010001000100010001000100010001000100010001000100010001000.

It may be that the tester caused the value of the double to become some kind of NaN value. (maybe NaN is displayed like this) That would definitely explain the length of the string.

Also, because of the restrictions of the slider class display showing only numbers, it was probably supposed to read 1x8888888888888888. Garbage in, garbage out?

Well, that's my guess.

like image 106
Nick Vaccaro Avatar answered Oct 24 '22 07:10

Nick Vaccaro