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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with float ( differnce between float and integer)

Problem with float ( differnce between float and integer)

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 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.
  • C Offline
    C Offline
    CHEICKNA TRAORE
    wrote on last edited by
    #1

    Hi, Here is code : CString Valeur="1250.20"; int Fractional = ((atof(Valeur) - atoi(Valeur)) * 100); Value of Fractional variable after thsi operation is 19 ( False ) I must be 20 Where is my error Thanks in advance

    H P 2 Replies Last reply
    0
    • C CHEICKNA TRAORE

      Hi, Here is code : CString Valeur="1250.20"; int Fractional = ((atof(Valeur) - atoi(Valeur)) * 100); Value of Fractional variable after thsi operation is 19 ( False ) I must be 20 Where is my error Thanks in advance

      H Offline
      H Offline
      Hadi Rezaee
      wrote on last edited by
      #2

      Hello, Try this one: CString Valeur="1250.20"; int Fractional = ((atof(Valeur) - atoi(Valeur)) * 100.0); change 100 to 100.0 My month article: Game programming by DirectX by Lan Mader. Please visit in: www.geocities.com/hadi_rezaie/index.html Hadi Rezaie

      1 Reply Last reply
      0
      • C CHEICKNA TRAORE

        Hi, Here is code : CString Valeur="1250.20"; int Fractional = ((atof(Valeur) - atoi(Valeur)) * 100); Value of Fractional variable after thsi operation is 19 ( False ) I must be 20 Where is my error Thanks in advance

        P Offline
        P Offline
        Pavel Klocek
        wrote on last edited by
        #3

        Result of atof-atoi is converted to int before multiplication. Pavel Sonork 100.15206

        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