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. Database & SysAdmin
  3. Database
  4. sql data types

sql data types

Scheduled Pinned Locked Moved Database
databasequestion
4 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.
  • S Offline
    S Offline
    saneng
    wrote on last edited by
    #1

    i m working on the stored procedures in SQL that computes the division of two columns having smallint as their datatype,for each row , the results are stored in a column of another table the datatype of the result is taken as float but it is correct upto 1 decimal place How do i increase the precision of float data type that gives the correct result "

    E 1 Reply Last reply
    0
    • S saneng

      i m working on the stored procedures in SQL that computes the division of two columns having smallint as their datatype,for each row , the results are stored in a column of another table the datatype of the result is taken as float but it is correct upto 1 decimal place How do i increase the precision of float data type that gives the correct result "

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      You could cast the two smallints to floating point numbers before doing te calculation. You can also cast the result to any precision you would like as well.

      A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

      S 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        You could cast the two smallints to floating point numbers before doing te calculation. You can also cast the result to any precision you would like as well.

        A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

        S Offline
        S Offline
        saneng
        wrote on last edited by
        #3

        7/1612 = 0.004342431761............. 6/1397 = 0.0042949176807................. above examples shows the division of 2 smallints giving a floating pt. result. but in our case I m getting the result column as 0.0 only for all values. y is this happening, y isn't it considering the whole result or atleast it should give 3 to 4 values after decimal.

        M 1 Reply Last reply
        0
        • S saneng

          7/1612 = 0.004342431761............. 6/1397 = 0.0042949176807................. above examples shows the division of 2 smallints giving a floating pt. result. but in our case I m getting the result column as 0.0 only for all values. y is this happening, y isn't it considering the whole result or atleast it should give 3 to 4 values after decimal.

          M Offline
          M Offline
          Mairaaj Khan
          wrote on last edited by
          #4

          Hi saneng In my tests i'm getting the full results which are: 7/1612 = 4.3424317617866E-03 6/1397 = 4.29491768074445E-03 I do the same. Values (of type smallint) are stored in one table, and division results (of type float) are stored in another table. Moreover with all my search I didn't find that how to change/set the precision + scale of float type. Its default precision is 53 which cannot be changed.

          saneng wrote:

          7/1612 = 0.004342431761............. 6/1397 = 0.0042949176807................. above examples shows the division of 2 smallints giving a floating pt. result. but in our case I m getting the result column as 0.0 only for all values. y is this happening, y isn't it considering the whole result or atleast it should give 3 to 4 values after decimal.

          I guess you are using some other type like numeric or decimal. If this is so then check and set its precision + scale value. Wish you all the best.

          _____________________________ Success is not something to wait for, its something to work for.

          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