What is NXT-G number format? We've been following this tutorial to connect a NXT 1.0 brick to a PC via Bluetooth.

We've been able to set up the communication, send and receive data in ASCII format.

However, whenever we try to send an integer and use it for calculations, it returns the wrong result.

For example, sending 60000:

TX: 00 09 00 05 60 EA 00 00 00

RX: 02 09 00


After adding 1, it returns the following:

TX: 00 13 0A 00 01

RX: 02 13 00 00 05 00 00 80 3F 00 ... (zeroes)


We've tried sending different numbers, but they all return the same value.

The NXT-G software is identical to that in the tutorial.

How does NXT-G handle the integer data type?
The NXT actually uses IEEE 794 32-bit floating point number format in little endian byte order. I like using this site for conversions.

So, to decode your messages:


  TX: 00 09 00 05 60 EA 00 00 00


Byte 0: 0x00 - response required

Byte 1: 0x09 - write message command

Byte 2: 0x00 - Mailbox 1

Byte 3: 0x05 - Message size of 5 bytes

Bytes 4-7: 0x60 0xEA 0x00 0x00 - since this is little endian, reverse the bytes, 0x0000EA60, which plugged into the conversion site gives us 8.4078E-41

Byte 8: 0x00 - null terminator

Then you add 1.0 on the NXT and return the result.


  RX: 02 13 00 00 05 00 00 80 3F 00 ... (zeroes)


Byte 0: 0x02 - return packet

Byte 1: 0x13 - message read command

Byte 2: 0x00 - success

Byte 3: 0x00 - Mailbox 1

Byte 4: 0x05 - message size of 5 bytes

Bytes 5-8: 0x00 0x00 0x80 0x3F - again, little endian, so reversing bytes gives 0x3F800000 and plugging in to the calculator gives 1.0

Bytes 9-63: 0x00... - padding



So, it looks like the NXT is doing exactly what you actually told it (8.4078E-41 + 1.0 = 1.0) rather than what you thought you told it (60000 + 1 = 60001).



Plugging 60000.0 into the calculator, it looks like your message should be

TX: 00 09 00 05 00 60 6a 47 00