blueoil icon indicating copy to clipboard operation
blueoil copied to clipboard

Avoid error comes from floating point literal decimal representation in code generation

Open primenumber opened this issue 4 years ago • 5 comments

Conversion between floating point value ↔ decimal string representation cause some small error. Several solution exists:

  • Using hexadecimal representation (But not allowed in C++14 standard)
  • Embedding as array of binary value and using memcpy

I think that second solution may be more preferred.

primenumber avatar Jun 02 '20 05:06 primenumber

I would like to know more about the second solution to prevent misunderstanding.

Do you intend to create a new binary file and load data from the file? Or do you intend to generate arrays like the one generated by the xxd -i command (an array of unsigned char that can be converted to an array of float or int with reinterpret_cast) and embed it in the source code?

It looks that the latter approch is better to me, because the amount of changes is likely less than the former.

tkng avatar Jun 04 '20 04:06 tkng

I supposed to embed data in the source code.

primenumber avatar Jun 04 '20 04:06 primenumber

I see. I agree to your idea.

Are you already working on this issue? If you haven't, would you mind if I worked on it?

tkng avatar Jun 04 '20 04:06 tkng

No, I haven't started yet.

primenumber avatar Jun 04 '20 04:06 primenumber

OK, I'll try.

tkng avatar Jun 04 '20 05:06 tkng