[RESOLVED] function gives 2 different outputs
Hi all,
I have a very strange thing going on...I got a lot the CheckErrorStatus (Int32) error...and so I started to dig into my created functions.
At the end I found what gave that error and so I added a new breakpoint on both computers where I want to run it (one is the developping computer, the other is the clients computer).
Developping computer : Windows 7, VS2008, .NET Framework 3.5SP1
Clients computer: Windows XP SP3, VS2008, .NET Framework 3.5SP1
the code of the function is a follows:
Code:
Function convert_nm_pixels_x(Byval distancex as Decimal) as Decimal
convert_nm_pixels_x = Math.Round((distancex*grid_ratio_x)/10 + Main.graph.Width/2,4)
end function
With distancex is in fact the X-part of a geographic coordinate
With grid_ratio_x is the ratio of how many pixels is 1degree...
graph.Width is the width of the picturebox.
Can somebody tell me, or give me some ideas how it can that with the same input this function gives 2 differents (of which one is fault) output?
Thanks in advance
Re: function gives 2 different outputs
Are the same values being passed in?
Is the value of Main.graph.Width the same?
Re: function gives 2 different outputs
yes, the same values are passed in...and yes the width is the same...
strange isn't it?
Re: function gives 2 different outputs
Break it down into different parts and show the workingout to find out which exact calculation is causing the problem.
Re: function gives 2 different outputs
Maybe the fact that geographic coordinate can become negative value can help you
Re: function gives 2 different outputs
Quote:
Originally Posted by
Geemuse
yes, the same values are passed in...and yes the width is the same...
strange isn't it?
If the values are the exact same then the output of that function will also be the exact same. Perhaps the problem isn't with this function but rather a related one?
Re: function gives 2 different outputs
Could you describe "different values"? It's possible that on different versions of Windows (particularly if one is x86 and the other is x64) that there will be small differences in calculation error. A coworker showed me something like this the other day; apparently Silverlight and the .NET Framework use slightly different precision for Double and it can lead to small calculation differences. It may or may not be a big deal.
If you can specify all of the inputs and the outputs you get, it'd be no problem for me to try it on XP 32-bit and a myriad of Vista/Win7 flavors.
Re: function gives 2 different outputs
so what do I mean by different values...
My computer (good output) gives e.g. 670 which is the x-position on the picturebox...which is good. The bad one gives 1.546432021E16 so no small error...
I think the best solution is what Grimfort says...stripping the rather small function down to its base.
I'll keep you up to date!!
Sitten Spynne --> this must be the reason for my CheckErrorStatus (the other post :-))
Re: function gives 2 different outputs
Yeah, that's definitely not a small platform-specific precision error. Perhaps grid_ratio_x is much larger than you think it should be on the "bad" system? I still say even if you follow Grimfort's advice there's no way anyone can reasonably reproduce the behavior without knowing the inputs.
Re: function gives 2 different outputs
One possible reason is: when you calculate, you did something divide like A/B. If B is very small, then it could generate big difference on different OS (i.e. 64 vs 32). In this situation, you can not simply do A/B, you will need simplify the equation, or, use high precision calculation which means you will need write function for / to get more accurate result.
this is normal in scientific calculation.
Re: function gives 2 different outputs
Hi all,
Just for all of you who helped me through this process...I found the answer.
Something quite stupid, but causing a lot of headaches :)
The problem was my language and regional settings.
On my clients pc it was en-US , so a "," is voor thousands and "." is decimal and I used the nl-BE system, where it's vice versa...
I'd like to thank everybody who helped me!!
Greetz
geemuse