10using System.Runtime.InteropServices;
14 public static class BitConverterNonAlloc_Template_ {
18 private static ConversionStruct _c;
27 public static Single ToSingle(
byte[] bytes,
int offset = 0) {
30 fixed (
void* ptr = &bytes[offset]) {
50 public static Single ToSingle(
byte[] bytes, ref
int offset) {
53 fixed (
void* ptr = &bytes[offset]) {
54 offset +=
sizeof(Single);
71 public static void GetBytes(Single value,
byte[] bytes,
int offset = 0) {
74 fixed (
void* ptr = &bytes[offset]) {
75 *(Single*)ptr = value;
94 public static void GetBytes(Single value,
byte[] bytes, ref
int offset) {
97 fixed (
void* ptr = &bytes[offset]) {
98 offset +=
sizeof(Single);
99 *(Single*)ptr = value;
110 [StructLayout(LayoutKind.Explicit)]
111 private struct ConversionStruct {
130 public UInt16 UInt16;
134 public UInt32 UInt32;
138 public UInt64 UInt64;
142 public Single Single;
144 public Double Double;