vb.net 2003 Editor typing problem
-
Hi, In my vb.net editor, when I type a double number like 6.35, it automatically is converted to 6.3499999999999996 when I leave the line I am typing. Can anyone tell me why it happens and how to avoid it?:confused: Thanks in advance, Vinicius
-
Hi, In my vb.net editor, when I type a double number like 6.35, it automatically is converted to 6.3499999999999996 when I leave the line I am typing. Can anyone tell me why it happens and how to avoid it?:confused: Thanks in advance, Vinicius
This is because of how numbers are stored internally by the system. There's no way to avoid it. Although, I'm not seeing the problem you're describing using Single or Double types. Can we see the code this is happening in?
Dave Kreskowiak Microsoft MVP - Visual Basic
-
This is because of how numbers are stored internally by the system. There's no way to avoid it. Although, I'm not seeing the problem you're describing using Single or Double types. Can we see the code this is happening in?
Dave Kreskowiak Microsoft MVP - Visual Basic
The code is simple:
Dim myVar as double myVar = 6.35
after typing 6.35, the editor changes it toDim myVar as double myVar = 6.3499999999999996
I understand it can be stored like that internally. What I don't understand is why in some projects it doesn't happen. Another problem I see is that if I try to use the "Text Find" resource in my project, to find a string like 6.35 I will never locate it, so why couldn't the editor leave my numbers exactlly as they are typed? The program I'm writing is working perfect, although these editor's changes, but it doesn't make me happy.:sigh: Vinicius -
This is because of how numbers are stored internally by the system. There's no way to avoid it. Although, I'm not seeing the problem you're describing using Single or Double types. Can we see the code this is happening in?
Dave Kreskowiak Microsoft MVP - Visual Basic
I found out that if the number has only one dacimal value, nothing changes:
Dim myVar as double myVar = 6.3
So, again, why? :confused::confused::confused: -
I found out that if the number has only one dacimal value, nothing changes:
Dim myVar as double myVar = 6.3
So, again, why? :confused::confused::confused: -
I found out that if the number has only one dacimal value, nothing changes:
Dim myVar as double myVar = 6.3
So, again, why? :confused::confused::confused: -
No, they are all double
-
I'll try SP1 Thanks
-
I'll try SP1 Thanks
I was already using SP1.