It might not seem logical to need to convert numbers to strings, but that is exactly what you must do if you're using the default "text" protocol. Consider using the libpqtypes
library, which takes care of lots of this detail for you.
You can use the binary protocol (on a param-by-param basis, see the documentation on PQexecParams
) ... but in general you're way better off using the text protocol. It's often actually faster on the network, particularly for lots of small numbers, and you don't have to worry about endianness and number format issues if you use the text protocol.