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

Asked 2 years ago, Updated 2 years ago, 89 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?
https://ja.wikipedia.org/wiki/%E5%8D%98%E7%B2%BE%E5%BA%A6%E6%B5%AE%E5%8B%95%E5%B0%8F%E6%95%B0%E7%82%B9%E6%95%B0
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


© 2024 OneMinuteCode. All rights reserved.