Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. vb calculation is diffrent than C# calculation [modified]

vb calculation is diffrent than C# calculation [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netregexhelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pankaj Saha
    wrote on last edited by
    #1

    Hi, I have a vb application, which contains lots of calculation and I am converting that application to asp.net C#. There are so many variables of double types in the vb application and I also took double in the c# for those variables. Now problem is that I do calculation with the same equation in both the application, however result value does not match. I have a variable var1 in vb the calculate double value is 1.63870925710649 (for vb) and 1.6387092571064941 (for c#), I do not understand why these values are different for the same datatype. And I have to use this variable in my equation, since both language has different value, this may be the reason of different final output. Some times I have to break the same equation into two or more equations for the C# , to get the same result in C# and sometimes I get the same result. But sometimes I get the value in c# which does not match the value of vb. I do not understand which calculation is right vb or C#.

    Pankaj

    modified on Tuesday, December 8, 2009 2:16 AM

    D D 2 Replies Last reply
    0
    • P Pankaj Saha

      Hi, I have a vb application, which contains lots of calculation and I am converting that application to asp.net C#. There are so many variables of double types in the vb application and I also took double in the c# for those variables. Now problem is that I do calculation with the same equation in both the application, however result value does not match. I have a variable var1 in vb the calculate double value is 1.63870925710649 (for vb) and 1.6387092571064941 (for c#), I do not understand why these values are different for the same datatype. And I have to use this variable in my equation, since both language has different value, this may be the reason of different final output. Some times I have to break the same equation into two or more equations for the C# , to get the same result in C# and sometimes I get the same result. But sometimes I get the value in c# which does not match the value of vb. I do not understand which calculation is right vb or C#.

      Pankaj

      modified on Tuesday, December 8, 2009 2:16 AM

      D Offline
      D Offline
      Dinesh Mani
      wrote on last edited by
      #2

      Both calculations are correct, except that the precision in C# is more than precision in VB 1.63870925710649 [VB] 1.6387092571064941 [C#] Just round off the value the number of digits required and use it!

      P 1 Reply Last reply
      0
      • D Dinesh Mani

        Both calculations are correct, except that the precision in C# is more than precision in VB 1.63870925710649 [VB] 1.6387092571064941 [C#] Just round off the value the number of digits required and use it!

        P Offline
        P Offline
        Pankaj Saha
        wrote on last edited by
        #3

        Thanks for your replay. But this is not the problem. How do I know how much digit I have to round up. There are more than 100 double variables and more than 100 complex calculation, then its very difficult to round each and every variable or calculated value, however in vb they did not use any round method.

        Pankaj

        D 1 Reply Last reply
        0
        • P Pankaj Saha

          Thanks for your replay. But this is not the problem. How do I know how much digit I have to round up. There are more than 100 double variables and more than 100 complex calculation, then its very difficult to round each and every variable or calculated value, however in vb they did not use any round method.

          Pankaj

          D Offline
          D Offline
          Dinesh Mani
          wrote on last edited by
          #4

          I understand that it can really be a pain in your scenario. How about doing the rounding off at specific check points? BTW, what is the system precision that is expected??

          1 Reply Last reply
          0
          • P Pankaj Saha

            Hi, I have a vb application, which contains lots of calculation and I am converting that application to asp.net C#. There are so many variables of double types in the vb application and I also took double in the c# for those variables. Now problem is that I do calculation with the same equation in both the application, however result value does not match. I have a variable var1 in vb the calculate double value is 1.63870925710649 (for vb) and 1.6387092571064941 (for c#), I do not understand why these values are different for the same datatype. And I have to use this variable in my equation, since both language has different value, this may be the reason of different final output. Some times I have to break the same equation into two or more equations for the C# , to get the same result in C# and sometimes I get the same result. But sometimes I get the value in c# which does not match the value of vb. I do not understand which calculation is right vb or C#.

            Pankaj

            modified on Tuesday, December 8, 2009 2:16 AM

            D Offline
            D Offline
            Dave Doknjas
            wrote on last edited by
            #5

            Can you provide an example of a calculation which doesn't give the same results? There are some subtle differences in math between C# and VB which could explain it.

            David Anton Convert between VB, C#, C++, & Java http://www.tangiblesoftwaresolutions.com

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups