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. Help with Decimal Roundings

Help with Decimal Roundings

Scheduled Pinned Locked Moved Database
csharphelpasp-netcom
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.
  • V Offline
    V Offline
    Vimalsoft Pty Ltd
    wrote on last edited by
    #1

    hi Guys , i am a bit stuck here i have this value "0.833333333333333" and i want the asnwer to be 83 , i tried this

    SELECT ROUND(0.833333333333333,2)

    but it does not work

    Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa[at]dotnetfunda.com http://www.Dotnetfunda.com

    L N 2 Replies Last reply
    0
    • V Vimalsoft Pty Ltd

      hi Guys , i am a bit stuck here i have this value "0.833333333333333" and i want the asnwer to be 83 , i tried this

      SELECT ROUND(0.833333333333333,2)

      but it does not work

      Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa[at]dotnetfunda.com http://www.Dotnetfunda.com

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      SELECT TRUNC(0.833333333333333 * 100)

      Add .5 prior to multiplying if you actually need to "round" the number.

      Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

      V 1 Reply Last reply
      0
      • L Lost User

        SELECT TRUNC(0.833333333333333 * 100)

        Add .5 prior to multiplying if you actually need to "round" the number.

        Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

        V Offline
        V Offline
        Vimalsoft Pty Ltd
        wrote on last edited by
        #3

        Thanks

        DECLARE @Value FLOAT = 0.833333333333333;
        SELECT CAST(@Value * 100 AS INT);

        Worked for me

        Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa[at]dotnetfunda.com http://www.Dotnetfunda.com

        1 Reply Last reply
        0
        • V Vimalsoft Pty Ltd

          hi Guys , i am a bit stuck here i have this value "0.833333333333333" and i want the asnwer to be 83 , i tried this

          SELECT ROUND(0.833333333333333,2)

          but it does not work

          Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa[at]dotnetfunda.com http://www.Dotnetfunda.com

          N Offline
          N Offline
          Niladri_Biswas
          wrote on last edited by
          #4

          Declare @X float = 0.833333333333333

          SELECT ROUND(@X*100,0)

          Niladri Biswas (Code Project MVP 2012)

          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