Results 1 to 11 of 11

Thread: [RESOLVED] function gives 2 different outputs

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Location
    Belgium
    Posts
    98

    Resolved [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

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: function gives 2 different outputs

    Are the same values being passed in?
    Is the value of Main.graph.Width the same?
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Location
    Belgium
    Posts
    98

    Re: function gives 2 different outputs

    yes, the same values are passed in...and yes the width is the same...

    strange isn't it?

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    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.

  5. #5
    Hyperactive Member Zeljko's Avatar
    Join Date
    Oct 2006
    Location
    Internet
    Posts
    441

    Re: function gives 2 different outputs

    Maybe the fact that geographic coordinate can become negative value can help you
    1. If this post helped you, please Rate it = That's You, saying Thanks, to Me ...Left side of this post: [Rate this post]
    2. Mark this Thread Resolved if your question has been answered That's You, saying Thanks, to Group ...Menu on top of your original Post: [Thread Tools]>[Mark Thread Resolved]
    3.
    Check my site: www.er-ef.netCheck my snippets: Get installed .NET versionsRegex extractingJoin hierarchically nested Datatables in one flattened Datatable


  6. #6
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: function gives 2 different outputs

    Quote Originally Posted by Geemuse View Post
    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?
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  7. #7
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    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.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Location
    Belgium
    Posts
    98

    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 :-))

  9. #9
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    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.

  10. #10
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    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.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Location
    Belgium
    Posts
    98

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width