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 assignment

problem with float assignment

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 4 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
    samosato
    wrote on last edited by
    #1

    I have following problem : I have condition and in netbeans its saying : warning: assignment makes integer from pointer without a cast if (var==varb+c) { sbod='b';} here is declaration : char sbod; float var,varb,c; any idea what might be worng with my condition ?

    L CPalliniC 3 Replies Last reply
    0
    • S samosato

      I have following problem : I have condition and in netbeans its saying : warning: assignment makes integer from pointer without a cast if (var==varb+c) { sbod='b';} here is declaration : char sbod; float var,varb,c; any idea what might be worng with my condition ?

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

      I did not understand your problem but as a general note, you must never directly compare floating point values. You will be surprised that it doesn't always work out and lead to subtle bugs. Google about comparing float values in C to find out more.

      ...byte till it megahertz... my donation to web rubbish

      S 1 Reply Last reply
      0
      • L Lost User

        I did not understand your problem but as a general note, you must never directly compare floating point values. You will be surprised that it doesn't always work out and lead to subtle bugs. Google about comparing float values in C to find out more.

        ...byte till it megahertz... my donation to web rubbish

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

        ok so is there any way how can I compare two variables which are float , int or other type ?

        G 1 Reply Last reply
        0
        • S samosato

          ok so is there any way how can I compare two variables which are float , int or other type ?

          G Offline
          G Offline
          gothic_coder
          wrote on last edited by
          #4

          Check This

          1 Reply Last reply
          0
          • S samosato

            I have following problem : I have condition and in netbeans its saying : warning: assignment makes integer from pointer without a cast if (var==varb+c) { sbod='b';} here is declaration : char sbod; float var,varb,c; any idea what might be worng with my condition ?

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

            Something strange about that message, although I guess you are getting an automatic cast from char to int. As mentioned in the previous answer, don't use == expressions to compare float values as they are always approximations, unless whole numbers, but even then you can lose precision with very large values.

            Just say 'NO' to evaluated arguments for diadic functions! Ash

            1 Reply Last reply
            0
            • S samosato

              I have following problem : I have condition and in netbeans its saying : warning: assignment makes integer from pointer without a cast if (var==varb+c) { sbod='b';} here is declaration : char sbod; float var,varb,c; any idea what might be worng with my condition ?

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              Maybe Neatbeans is drunk or you reported the wrong piece of code, please check for both possibilities. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              In testa che avete, signor di Ceprano?

              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