D-YAML icon indicating copy to clipboard operation
D-YAML copied to clipboard

double is a better then real

Open 9il opened this issue 4 years ago • 9 comments

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

9il avatar Jul 04 '21 02:07 9il

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

Geod24 avatar Jul 25 '22 16:07 Geod24

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.

Herringway avatar Jul 25 '22 16:07 Herringway

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

Geod24 avatar Jul 25 '22 16:07 Geod24

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

9il avatar Jul 25 '22 17:07 9il

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 avatar Jul 25 '22 18:07 Herringway

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.

Herringway avatar Jul 25 '22 18:07 Herringway

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

9il avatar Jul 25 '22 19:07 9il

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

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

Herringway avatar Jul 25 '22 22:07 Herringway

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

9il avatar Jul 26 '22 16:07 9il