haxe/src/haxe/io/FPHelper.cs
// Generated by Haxe 4.3.7 (patched: no StructLayout/FieldOffset)

#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe.io {
	public class FPHelper : global::haxe.lang.HxObject {
		
		public FPHelper(global::haxe.lang.EmptyObject empty) {
		}
		
		
		public FPHelper() {
			global::haxe.io.FPHelper.__hx_ctor_haxe_io_FPHelper(this);
		}
		
		
		protected static void __hx_ctor_haxe_io_FPHelper(global::haxe.io.FPHelper __hx_this) {
		}
		
		
		private static int SwapInt32(int i) {
			unchecked {
				uint v = (uint)i;
				v = (v >> 24) |
					((v >> 8) & 0x0000FF00u) |
					((v << 8) & 0x00FF0000u) |
					(v << 24);
				return (int)v;
			}
		}
		
		
		private static long SwapInt64(long i) {
			unchecked {
				ulong v = (ulong)i;
				v = (v >> 56) |
					((v >> 40) & 0x000000000000FF00UL) |
					((v >> 24) & 0x0000000000FF0000UL) |
					((v >> 8) & 0x00000000FF000000UL) |
					((v << 8) & 0x000000FF00000000UL) |
					((v << 24) & 0x0000FF0000000000UL) |
					((v << 40) & 0x00FF000000000000UL) |
					(v << 56);
				return (long)v;
			}
		}
		
		
		public static double i32ToFloat(int i) {
			unchecked {
				if ( ! (global::System.BitConverter.IsLittleEndian) ) {
					i = global::haxe.io.FPHelper.SwapInt32(i);
				}
				
				float f = global::System.BitConverter.Int32BitsToSingle(i);
				return ((double) (f) );
			}
		}
		
		
		public static int floatToI32(double f) {
			unchecked {
				int i = global::System.BitConverter.SingleToInt32Bits(((float) (f) ));
				if ( ! (global::System.BitConverter.IsLittleEndian) ) {
					i = global::haxe.io.FPHelper.SwapInt32(i);
				}
				
				return i;
			}
		}
		
		
		public static double i64ToDouble(int low, int high) {
			unchecked {
				long bits = ((long) (( ( ((long) (high) ) << 32 ) | ( ((long) (low) ) & 0xffffffffL ) )) );
				if ( ! (global::System.BitConverter.IsLittleEndian) ) {
					bits = global::haxe.io.FPHelper.SwapInt64(bits);
				}
				
				return global::System.BitConverter.Int64BitsToDouble(bits);
			}
		}
		
		
		public static long doubleToI64(double v) {
			unchecked {
				long bits = global::System.BitConverter.DoubleToInt64Bits(v);
				if ( ! (global::System.BitConverter.IsLittleEndian) ) {
					bits = global::haxe.io.FPHelper.SwapInt64(bits);
				}
				
				return bits;
			}
		}
		
		
	}
}