6 Replies Latest reply on Aug 8, 2018 4:03 AM by user_3617441

    Integer(Int) to Float number

      Hi There!


      I'm using CY8CKIT-059 I'm codding this on PSOC Creator 4.2 So I need some help


      My problem is;

      I have 32bit anolog input from potantiometer. IT is around 0-65930 So I want to see this around 0-5,000V  


      I made it 0-5000 mV  but I couldn't do 0-5,000V  


      So how can I do it?

        • 1. Re: Integer(Int) to Float number

          double Result;

          Result = mV / 1000.0;   // Will convert to float


          Happy coding


          • 2. Re: Integer(Int) to Float number

            The 32 bit analog input from your potentiometer can be mapped to the data range 0 - (2³²-1) which is essentially 4 bytes and unsigned int data type can easily accommodate this. However, if you want the data type to store decimal values, you can use the float data type which is also 4 bytes.


            uint32 potentiometerInt; // Unsigned int


            float potentiometerFloat //float


            If you want to convert from one data type to another you can just type cast it.

            potentiometerFloat = (float) potentiometerInt


            I didn't understand what you meant by 0-5000V, the voltage of the potentiometer can't be of such high value, are you talking about the count? What do you mean by i made it 0 - 5000mV, please clarify.




            • 3. Re: Integer(Int) to Float number

              Thank you so much


              0-5000mV means my converted output from potantiometer input when my potantiometer ohm is nearly 0 my output voltage from potantiometer


              is 5v so 5000mV 


              So i want to  print float number on LCD  i have got input from potantiometer and it is 32bit (int32) so data range


              0 to (2^32-1) my problem is I cannot print after point(.) on LCD such as  my converted output is 5,238V but I cannot printing ,238


              on LCD my problem is this I can printing 5238mV but cannot that one

              • 4. Re: Integer(Int) to Float number

                Thanks you much


                and now how can i print float or double numbers on LCD i cannot printing after point( . )


                suach as my float or double is 5,342 i cannot printing ,342

                • 5. Re: Integer(Int) to Float number

                  Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use

                  Creator->File->Create Workspace Bundle (minimal)

                  and attach the resulting file.



                  • 6. Re: Integer(Int) to Float number

                    I'm sorry man i fixed it now you were right I just forget change the heap size now is working thanks for your helpfull


                    best regards.