Re: How to convert numbers from Binary to Decimal? Please Coment!:D

fnb111:
Member.

In another post called radio.write I was told that the data I received is in binary. I coppied the above code mentioned in #3 into my receiver and it only returns a numbr of 170. It should print a decimal vaue of -0.61

The data I receive currently is gubberish.

Any ideas on how to fix this?

Thanks in advance

ALL integer values are stored as binary - it is the ONLY way they can stored in a digital MCU.

The difference arises when you print them out to some sort of display device.

In the case of serial monitor you can chose to display the value as the native binary number: Serial.println(10, BIN)

Or as a more intuitive decimal number Serial.println(10, DEC)....or just Serial.println(10)

When reading integer data from a hardware device you simply don't need to concern yourself as to whether the data is binary or decimal. Such a concern is totally irrelevant.

Just declare an integer variable or variables and read the integer values into those variables.

Then you can chose how you want to display those rad values in Serial monitor for example - as a binary number of a decimal number.