Otp.OtpOutputStream.write_double C# (CSharp) Метод

write_double() публичный Метод

public write_double ( double d ) : void
d double
Результат void
        public virtual void  write_double(double d)
        {
            this.write1(OtpExternal.newFloatTag);

            byte[] data = BitConverter.GetBytes(d);
            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(data);
            }
            this.write(data);
            /*
            double val;
            int exp = 0;
            int sign = 0;
            System.String str;
            
            // remove sign to simplify decimal shift
            if (d >= 0)
            {
                val = d;
            }
            else
            {
                sign = 1;
                val = - d;
            }
            
            // move the decimal point until we have a single units digit
            if (System.Math.Sign(val) != 0)
            {
                // until greater than or equal to 1.0  -> multiply by 10
                while (val < 1.0)
                {
                    val *= 10;
                    exp--;
                }
                // until strictly less than 10.0 -> divide by 10
                while (val >= 10.0)
                {
                    val /= 10;
                    exp++;
                }
            }

            // get 20 decimal digits, put sign back, add new exponent
            //UPGRADE_TODO: The equivalent in .NET�for Class C#.math.BigDecimal.ROUND_HALF_EVEN will be considered in a future release.;
            //val = val.setScale(20, BigDecimal.ROUND_HALF_EVEN);
            //UPGRADE_TODO: The equivalent in .NET�for Class C#.math.BigDecimal.toString will be considered in a future release.;
            str = (sign == 1?"-":"") + System.Convert.ToString(val) + "e" + System.Convert.ToString(exp);

            // write the value
            this.write1(OtpExternal.floatTag);
            //UPGRADE_NOTE: This code will be optimized in the future;
            byte[] tmpBytes;
            int i;
            string tmpStr;
            tmpStr = str;
            tmpBytes = new byte[tmpStr.Length];
            i = 0;
            while (i < tmpStr.Length)
            {
                tmpBytes[i] = (byte) tmpStr[i];
                i++;
            }
            this.writeN(tmpBytes);
            
            // pad with zeros to 31 bytes
            //UPGRADE_NOTE: This code will be optimized in the future;
            byte[] tmpBytes2;
            int i2;
            string tmpStr2;
            tmpStr2 = str;
            tmpBytes2 = new byte[tmpStr2.Length];
            i2 = 0;
            while (i2 < tmpStr2.Length)
            {
                tmpBytes2[i2] = (byte) tmpStr2[i2];
                i2++;
            }
            int i3 = (int) (tmpBytes2.Length);
             for (; i3 < 31; i3++)
                this.write1(0);
            */
        }