Can anyone explain this strange behavior with signed floats in C#?

前端 未结 11 2048
别跟我提以往
别跟我提以往 2020-12-07 07:17

Here is the example with comments:

class Program
{
    // first version of structure
    public struct D1
    {
        public double d;
        public int f         


        
11条回答
  •  天涯浪人
    2020-12-07 07:41

    If you make D2 like this

    public struct D2
    {
        public double d;
        public double f;
        public string s;
    }
    

    it's true.

    if you make it like this

    public struct D2
    {
        public double d;
        public double f;
        public double u;
    }
    

    It's still false.

    it seems like it's false if the struct only holds doubles.

提交回复
热议问题