I want to write with float when I write csv with go.

Asked 5 months ago, Updated 5 months ago, 16 views

I'm trying to write csv using go language, but
For some reason, I'm asking you to write in float instead of string.
There is a white function in the csv package, but the argument must be a slice of string, and the contents of the written csv will also be string.

Is there any good way?

go csv

2022-09-30 11:48

1 Answers

Since CSV is a "text file" called Comma Separated Values,
Convert float to a string and write
Read while converting the string to float
I guess there's nothing for it.

It's hard for readers to understand the meaning of "as it is", but
By any chance, do you want the internal expression of float to be written in hexadecimal and put into CSV format?
According to
, for example,
+1.0 is 3F8000
-2.0 is C00000
Therefore, 3F800000, C0000000, is available as CSV format text.
(I don't know if there's a tool to read that CSV in floating-point format.)

2022-09-30 11:48

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.