dlang-community / D-YAML

YAML parser and emitter for the D programming language
https://dlang-community.github.io/D-YAML/
Boost Software License 1.0
118 stars 38 forks source link

double is a better then real #270

Open 9il opened 3 years ago

9il commented 3 years ago

Excess precision cause looses in precision when converted to/form decimal representation. Almost all other non D YAML implementations uses double.

Geod24 commented 2 years ago

@Herringway : I think that's an issue we should address. real is also much slower than double.

Herringway commented 2 years ago

Yes, but replacing real with double has different issues. Nodes really shouldn't be using floating point (or other scalar types aside from string) internally.

Geod24 commented 2 years ago

So should we just keep the string representation and convert on demand ?

9il commented 2 years ago

How would you construct a Node then when you need to convert another format to YAML?

Herringway commented 2 years ago

So should we just keep the string representation and convert on demand ?

Yes. That would keep the conversions to a minimum and allow values not perfectly representable by floating point types to be preserved between saves/loads.

Herringway commented 2 years ago

How would you construct a Node then when you need to convert another format to YAML?

It would not be much different than it is now. This may not even need changes to the interface.

9il commented 2 years ago

Would you convert floating to string to store it in Node?

Herringway commented 2 years ago

Would you convert floating to string to store it in Node?

Yes. It would be difficult to write it to the file otherwise.

9il commented 2 years ago

Mir has precise number printing that produces the minimal prices decimal form of a given floating point number.