Converting double to char* in C++ with high performance

后端 未结 8 1544
野趣味
野趣味 2020-12-15 04:23

My application needs to convert double values to char* to write to a pipe that accepts only characters. The usual ways of doing this are using the sprintf() functio

8条回答
  •  眼角桃花
    2020-12-15 04:56

    Are you in control of both ends of the pipe? Are you just trying to tunnel doubles through or do you need a valid text representation of the double?

    If you are just tunneling and the pipe is 8 bit clean then use one of the answers above.

    If you need a string use one of the other answers above.

    If your problem is that the pipe is only 7 bits wide, then convert to radix 64 on write and back again on read.

提交回复
热议问题