Anonymous
Not applicable

# 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 Solution
Level 10
Level 10

# Re: Integer(Int) to Float number

double Result;

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

Happy coding

Bob

6 Replies
Level 10
Level 10

# Re: Integer(Int) to Float number

double Result;

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

Happy coding

Bob

Anonymous
Not applicable

# 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

Level 10
Level 10

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

Bob

Anonymous
Not applicable

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

Moderator
Moderator

# 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

OR

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.

Regards,

Dheeraj

Anonymous
Not applicable