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. integer

integer

Scheduled Pinned Locked Moved Visual Basic
helpquestiontutorial
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.
  • P Offline
    P Offline
    pnpfriend
    wrote on last edited by
    #1

    Hello, I have following code Dim i As Integer i = 3/2 from my knowleadge, if you set the variable as an integer, when you divide, (from the example) suppose to be i= 1 but right now i=2 because the answer i = 1.5 and automatically set the i to 2 . why is that? I don't want the decimal numbers, I want the integer. How can I fix that problem Thanks

    J X 2 Replies Last reply
    0
    • P pnpfriend

      Hello, I have following code Dim i As Integer i = 3/2 from my knowleadge, if you set the variable as an integer, when you divide, (from the example) suppose to be i= 1 but right now i=2 because the answer i = 1.5 and automatically set the i to 2 . why is that? I don't want the decimal numbers, I want the integer. How can I fix that problem Thanks

      J Offline
      J Offline
      Jason McBurney
      wrote on last edited by
      #2

      From my knowlage of vb, when it preforms type casting for you, it will always try to round. More information on this in the MSDN under cint(). If you just want to truncate your number, in this case either fix() or int() will do the job, however there is a subtle difference (regarding negetives) between them. Try: i = int(3/2) Now i = 1

      P 1 Reply Last reply
      0
      • J Jason McBurney

        From my knowlage of vb, when it preforms type casting for you, it will always try to round. More information on this in the MSDN under cint(). If you just want to truncate your number, in this case either fix() or int() will do the job, however there is a subtle difference (regarding negetives) between them. Try: i = int(3/2) Now i = 1

        P Offline
        P Offline
        pnpfriend
        wrote on last edited by
        #3

        thanks

        1 Reply Last reply
        0
        • P pnpfriend

          Hello, I have following code Dim i As Integer i = 3/2 from my knowleadge, if you set the variable as an integer, when you divide, (from the example) suppose to be i= 1 but right now i=2 because the answer i = 1.5 and automatically set the i to 2 . why is that? I don't want the decimal numbers, I want the integer. How can I fix that problem Thanks

          X Offline
          X Offline
          xBlitzerx
          wrote on last edited by
          #4

          its rounding up... .5 or higher rounds it up.. i believe there is a function to format numbers...i can't remember it though..sorry "I'm not me when I dream...anymore." -TRUSTcompany

          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