Closed 463728946 closed 5 years ago
I don’t think the decimal type is supported. I would recommend using float instead.
From: 463728946 notifications@github.com Sent: Thursday, June 13, 2019 9:18 PM To: jefffhaynes/BinarySerializer Cc: Subscribed Subject: [jefffhaynes/BinarySerializer] How to Bind Datetime and customer like Latitude Longitude (#132)
public class Test { [FieldOrder(0)] [FieldLength(4)] public Datetime UpdateTime {get;set;}
[FieldOrder(1)] [FieldLength(4)] public decimal Latitude { get; set; }
[FieldOrder(2)] [FieldLength(4)] public decimal Longitude { get; set; }
}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/BinarySerializer/issues/132?email_source=notifications&email_token=ACKIURYP4PI63ZXPQTZCKUDP2LWWVA5CNFSM4HYCUR22YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GZOJOUA, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACKIUR6ZTUTK6OZ7MRBGFTLP2LWWVANCNFSM4HYCUR2Q.
sorry ,I don't get it
Looks like you're expecting big endian. Try this:
public class Coordinates
{
[FieldOrder(0)]
[FieldScale(10000000)]
[SerializeAs(SerializedType.Int4)]
[FieldEndianness(Endianness.Big)]
public double Longitude { get; set; }
[FieldOrder(1)]
[FieldScale(10000000)]
[SerializeAs(SerializedType.Int4)]
[FieldEndianness(Endianness.Big)]
public double Latitude { get; set; }
}
amazing!It's great. thank u so much
var bytes = new byte[]{0x0D,0x74,0x51,0x78,0x43,0x8E,0x6E,0xC4}; //They should be: //Latitude [22.5726840] //Longitude [113.3407940] // //but they are: //Latitude -99.9387581 //Longitude 201.8604045
public class Coordinates { [FieldOrder(0)] [FieldScale(10000000)] [SerializeAs(SerializedType.Int4)] public double Longitude { get; set; } [FieldOrder(1)] [FieldScale(10000000)] [SerializeAs(SerializedType.Int4)] public double Latitude { get; set; } }