سؤال

my C# project is reading some configurations from a QML file.

The thing is that i'm not sure about some convertions...

QML        C#
int    <-> int
string <-> string
bool   <-> bool

are OK

I'm not sure about real/double in QML (to float/double in C#) I looked for some info about precisions but didn't find anything very clear.

Does double in QML is equivalent to double in C# ? Does real in QML is equivalent to float in C# ?

هل كانت مفيدة؟

المحلول

The C# spec says :

C# supports two floating point types: float and double. The float and double types are represented using the 32-bit single-precision and 64-bit double-precision IEEE 754 formats

So the only difference between float and double is the precision in C#.

The QML reference says for Double:

A double number has a decimal point and is stored in double precision, IEEE floating point format.

and for the real

In QML all reals are stored in single precision, IEEE floating point format.

They respect each other the IEEE 754 standard. So the only difference between real and double in QML is the precision too.

According to this table, it could be a good idea to parse C# float type as a real QML type and parse C# double type to double in QML.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top