void WriteStreamDouble(this Stream stream, int offset, double value, bool little) { #if SAFE_CAST byte[] intBytes = new byte[8]; fixed(byte *bs = intBytes) { double *c = (double *)bs; *c = value; if (BitConverter.IsLittleEndian != little) { Reverse8(c); } } stream.Position = offset; stream.Write(intBytes, 0, intBytes.Length); #else if (BitConverter.IsLittleEndian == little) { DoubleField fs = new DoubleField(value); fs.Fill(stream, offset); } else { RDoubleField fs = new RDoubleField(value); fs.Fill(stream, offset); } #endif }
void WriteDouble(this byte[] arr, int offset, double value, bool little) { #if SAFE_CAST fixed(byte *bs = arr) { double *target = (double *)(bs + offset); (*target) = value; } if (BitConverter.IsLittleEndian != little) { Reverse(arr, offset, 8); } #else if (BitConverter.IsLittleEndian == little) { DoubleField fs = new DoubleField(value); fs.Fill(arr, offset); } else { RDoubleField fs = new RDoubleField(value); fs.Fill(arr, offset); } #endif }