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. General Programming
  3. Visual Basic
  4. datatype [modified]

datatype [modified]

Scheduled Pinned Locked Moved Visual Basic
csharp
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.
  • A Offline
    A Offline
    Ankit Aneja
    wrote on last edited by
    #1

    Hi All, I am selecting weight Select instanceid2400,CAST(weight as real) as GrossWeight from tblcargo where instanceid2400='#AGE019000016' and result is 3289.154 but when I am reading it in vb.net as Dim GrossWeight as Single GrossWeight = .GetFloat("GrossWeight") it is changing value to 3289.1 and when i am using Dim GrossWeight as Double GrossWeight = .GetFloat("GrossWeight") it is putting unwanted values at end 3289.15405273438 how can we show same value (3289.154) whatever is selected

    Ankit Aneja "Nothing is impossible. The word itself says - I M possible"

    modified on Friday, May 15, 2009 9:36 AM

    D 1 Reply Last reply
    0
    • A Ankit Aneja

      Hi All, I am selecting weight Select instanceid2400,CAST(weight as real) as GrossWeight from tblcargo where instanceid2400='#AGE019000016' and result is 3289.154 but when I am reading it in vb.net as Dim GrossWeight as Single GrossWeight = .GetFloat("GrossWeight") it is changing value to 3289.1 and when i am using Dim GrossWeight as Double GrossWeight = .GetFloat("GrossWeight") it is putting unwanted values at end 3289.15405273438 how can we show same value (3289.154) whatever is selected

      Ankit Aneja "Nothing is impossible. The word itself says - I M possible"

      modified on Friday, May 15, 2009 9:36 AM

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Change the Single to Decimal...

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      Z 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Change the Single to Decimal...

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        Z Offline
        Z Offline
        Zaegra
        wrote on last edited by
        #3

        And if still facing trouble use .ToString("0.000") ..

        Motivation is the key to software development.

        D 1 Reply Last reply
        0
        • Z Zaegra

          And if still facing trouble use .ToString("0.000") ..

          Motivation is the key to software development.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Wrong. The value he's getting is because of the conversion from one floating point format to another. Formatting it to hide the inaccuracies does nothing when the value is used in calculations.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          Z 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Wrong. The value he's getting is because of the conversion from one floating point format to another. Formatting it to hide the inaccuracies does nothing when the value is used in calculations.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            Z Offline
            Z Offline
            Zaegra
            wrote on last edited by
            #5

            Ankit Aneja wrote:

            show same value

            I didn't mean to do this (.ToString) during the calculations, but after the calculations, only for showing the correct number (which in fact is wrong, I see that) :)

            Motivation is the key to software development.

            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