Re: NMS byte order for doubles
Done Hiram Chirino wrote: > > Could you attach your patch to that issue and make sue your click the > "Grant license to ASF for inclusion in ASF works (as per the Apache > Software License )" option. > > Thanks. > > On 1/11/07, rousseau <[EMAIL PROTECTED]> wrote: >> >> Sure. It's the same as AMQ-866. Comment added on that case. >> >> thx >> Steve >> >> >> >> Hiram Chirino wrote: >> > >> > Hi Steve, >> > >> > I would be happy to apply your patch but could you open a JIRA issue >> at: >> > http://issues.apache.org/activemq/browse/AMQ >> > >> > And attach your patch to that so that we have it properly documented >> > that you want to contribute your patch to the ASF. >> > >> > Thanks! >> > Hiram >> > >> > On 1/10/07, rousseau <[EMAIL PROTECTED]> wrote: >> >> >> >> I've found a byte-order problem sending a double from Java ActiveMQ to >> a >> >> NMS/CSharp receiver: >> >> >> >> (NMS) ActiveMQ.OpenWire.OpenWireBinaryReader has no definition for >> >> ReadDouble(), and by default calls the MS .NET >> BinaryReader.ReadDouble() >> >> which reads the bytes in the wrong order. Here is the fix: >> >> >> >> add a new method to OpenWireBinaryReader.cs: >> >> >> >> public override double ReadDouble() >> >> { >> >> return EndianSupport.SwitchEndian(base.ReadBytes(8)); >> >> } >> >> >> >> add a new method to EndianSupport.cs: >> >> >> >> public static double SwitchEndian(byte[] bytes) >> >> { >> >> //Reverse byte array >> >> byte[] reverse = new byte[8]; >> >> reverse[0] = bytes[7]; >> >> reverse[1] = bytes[6]; >> >> reverse[2] = bytes[5]; >> >> reverse[3] = bytes[4]; >> >> reverse[4] = bytes[3]; >> >> reverse[5] = bytes[2]; >> >> reverse[6] = bytes[1]; >> >> reverse[7] = bytes[0]; >> >> BinaryReader br = new BinaryReader(new >> >> MemoryStream(reverse)); >> >> return br.ReadDouble(); >> >> } >> >> >> >> If anyone knows a cleaner way of doing this, please let me know. >> >> >> >> thx >> >> /Steve >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8253895 >> >> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com. >> >> >> >> >> > >> > >> > -- >> > Regards, >> > Hiram >> > >> > Blog: http://hiramchirino.com >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8273932 >> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com. >> >> > > > -- > Regards, > Hiram > > Blog: http://hiramchirino.com > > -- View this message in context: http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8296882 Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: NMS byte order for doubles
Could you attach your patch to that issue and make sue your click the "Grant license to ASF for inclusion in ASF works (as per the Apache Software License )" option. Thanks. On 1/11/07, rousseau <[EMAIL PROTECTED]> wrote: Sure. It's the same as AMQ-866. Comment added on that case. thx Steve Hiram Chirino wrote: > > Hi Steve, > > I would be happy to apply your patch but could you open a JIRA issue at: > http://issues.apache.org/activemq/browse/AMQ > > And attach your patch to that so that we have it properly documented > that you want to contribute your patch to the ASF. > > Thanks! > Hiram > > On 1/10/07, rousseau <[EMAIL PROTECTED]> wrote: >> >> I've found a byte-order problem sending a double from Java ActiveMQ to a >> NMS/CSharp receiver: >> >> (NMS) ActiveMQ.OpenWire.OpenWireBinaryReader has no definition for >> ReadDouble(), and by default calls the MS .NET BinaryReader.ReadDouble() >> which reads the bytes in the wrong order. Here is the fix: >> >> add a new method to OpenWireBinaryReader.cs: >> >> public override double ReadDouble() >> { >> return EndianSupport.SwitchEndian(base.ReadBytes(8)); >> } >> >> add a new method to EndianSupport.cs: >> >> public static double SwitchEndian(byte[] bytes) >> { >> //Reverse byte array >> byte[] reverse = new byte[8]; >> reverse[0] = bytes[7]; >> reverse[1] = bytes[6]; >> reverse[2] = bytes[5]; >> reverse[3] = bytes[4]; >> reverse[4] = bytes[3]; >> reverse[5] = bytes[2]; >> reverse[6] = bytes[1]; >> reverse[7] = bytes[0]; >> BinaryReader br = new BinaryReader(new >> MemoryStream(reverse)); >> return br.ReadDouble(); >> } >> >> If anyone knows a cleaner way of doing this, please let me know. >> >> thx >> /Steve >> -- >> View this message in context: >> http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8253895 >> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com. >> >> > > > -- > Regards, > Hiram > > Blog: http://hiramchirino.com > > -- View this message in context: http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8273932 Sent from the ActiveMQ - Dev mailing list archive at Nabble.com. -- Regards, Hiram Blog: http://hiramchirino.com
Re: NMS byte order for doubles
Sure. It's the same as AMQ-866. Comment added on that case. thx Steve Hiram Chirino wrote: > > Hi Steve, > > I would be happy to apply your patch but could you open a JIRA issue at: > http://issues.apache.org/activemq/browse/AMQ > > And attach your patch to that so that we have it properly documented > that you want to contribute your patch to the ASF. > > Thanks! > Hiram > > On 1/10/07, rousseau <[EMAIL PROTECTED]> wrote: >> >> I've found a byte-order problem sending a double from Java ActiveMQ to a >> NMS/CSharp receiver: >> >> (NMS) ActiveMQ.OpenWire.OpenWireBinaryReader has no definition for >> ReadDouble(), and by default calls the MS .NET BinaryReader.ReadDouble() >> which reads the bytes in the wrong order. Here is the fix: >> >> add a new method to OpenWireBinaryReader.cs: >> >> public override double ReadDouble() >> { >> return EndianSupport.SwitchEndian(base.ReadBytes(8)); >> } >> >> add a new method to EndianSupport.cs: >> >> public static double SwitchEndian(byte[] bytes) >> { >> //Reverse byte array >> byte[] reverse = new byte[8]; >> reverse[0] = bytes[7]; >> reverse[1] = bytes[6]; >> reverse[2] = bytes[5]; >> reverse[3] = bytes[4]; >> reverse[4] = bytes[3]; >> reverse[5] = bytes[2]; >> reverse[6] = bytes[1]; >> reverse[7] = bytes[0]; >> BinaryReader br = new BinaryReader(new >> MemoryStream(reverse)); >> return br.ReadDouble(); >> } >> >> If anyone knows a cleaner way of doing this, please let me know. >> >> thx >> /Steve >> -- >> View this message in context: >> http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8253895 >> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com. >> >> > > > -- > Regards, > Hiram > > Blog: http://hiramchirino.com > > -- View this message in context: http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8273932 Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: NMS byte order for doubles
Hi Steve, I would be happy to apply your patch but could you open a JIRA issue at: http://issues.apache.org/activemq/browse/AMQ And attach your patch to that so that we have it properly documented that you want to contribute your patch to the ASF. Thanks! Hiram On 1/10/07, rousseau <[EMAIL PROTECTED]> wrote: I've found a byte-order problem sending a double from Java ActiveMQ to a NMS/CSharp receiver: (NMS) ActiveMQ.OpenWire.OpenWireBinaryReader has no definition for ReadDouble(), and by default calls the MS .NET BinaryReader.ReadDouble() which reads the bytes in the wrong order. Here is the fix: add a new method to OpenWireBinaryReader.cs: public override double ReadDouble() { return EndianSupport.SwitchEndian(base.ReadBytes(8)); } add a new method to EndianSupport.cs: public static double SwitchEndian(byte[] bytes) { //Reverse byte array byte[] reverse = new byte[8]; reverse[0] = bytes[7]; reverse[1] = bytes[6]; reverse[2] = bytes[5]; reverse[3] = bytes[4]; reverse[4] = bytes[3]; reverse[5] = bytes[2]; reverse[6] = bytes[1]; reverse[7] = bytes[0]; BinaryReader br = new BinaryReader(new MemoryStream(reverse)); return br.ReadDouble(); } If anyone knows a cleaner way of doing this, please let me know. thx /Steve -- View this message in context: http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8253895 Sent from the ActiveMQ - Dev mailing list archive at Nabble.com. -- Regards, Hiram Blog: http://hiramchirino.com
NMS byte order for doubles
I've found a byte-order problem sending a double from Java ActiveMQ to a NMS/CSharp receiver: (NMS) ActiveMQ.OpenWire.OpenWireBinaryReader has no definition for ReadDouble(), and by default calls the MS .NET BinaryReader.ReadDouble() which reads the bytes in the wrong order. Here is the fix: add a new method to OpenWireBinaryReader.cs: public override double ReadDouble() { return EndianSupport.SwitchEndian(base.ReadBytes(8)); } add a new method to EndianSupport.cs: public static double SwitchEndian(byte[] bytes) { //Reverse byte array byte[] reverse = new byte[8]; reverse[0] = bytes[7]; reverse[1] = bytes[6]; reverse[2] = bytes[5]; reverse[3] = bytes[4]; reverse[4] = bytes[3]; reverse[5] = bytes[2]; reverse[6] = bytes[1]; reverse[7] = bytes[0]; BinaryReader br = new BinaryReader(new MemoryStream(reverse)); return br.ReadDouble(); } If anyone knows a cleaner way of doing this, please let me know. thx /Steve -- View this message in context: http://www.nabble.com/NMS-byte-order-for-doubles-tf2951266.html#a8253895 Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.