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. C#
  4. Datatypes conversion [modified]

Datatypes conversion [modified]

Scheduled Pinned Locked Moved C#
winformsquestion
2 Posts 2 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
    VK Cadec
    wrote on last edited by
    #1

    Hi, I have this formula - Double i_decel_rate = ((Convert.ToInt32(textbox1.Text) * 10000) / Convert.ToInt32(textbox2.Text)); But for some reason the double doesn't display as double - like a value 7.98 is shown as 7 - it is not showing the decimals - but does display the integer value. I am using a text box to display this value - is there a way in webforms to print a value? Like the windows forms has messagebox.show()? is anything off with the syntax? thanks.

    modified on Monday, December 10, 2007 8:41:47 AM

    J 1 Reply Last reply
    0
    • V VK Cadec

      Hi, I have this formula - Double i_decel_rate = ((Convert.ToInt32(textbox1.Text) * 10000) / Convert.ToInt32(textbox2.Text)); But for some reason the double doesn't display as double - like a value 7.98 is shown as 7 - it is not showing the decimals - but does display the integer value. I am using a text box to display this value - is there a way in webforms to print a value? Like the windows forms has messagebox.show()? is anything off with the syntax? thanks.

      modified on Monday, December 10, 2007 8:41:47 AM

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      VK-Cadec wrote:

      is anything off with the syntax?

      Yes, if you do division using integers the result is an integer (as you've found). Double i_decel_rate = ((Convert.ToDouble(textbox1.Text) * 10000.0) / Convert.ToDouble(textbox2.Text));

      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