110,571
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
float ft = 999999.999f;
byte[] bytes = BitConverter.GetBytes(ft);
unsafe
{
IntPtr i2= Marshal.AllocHGlobal(bytes.Length);
Marshal.Copy(bytes, 0, i2, bytes.Length);
byte *buf1 = (byte*)QtyToBuf((byte *)i2, 8);
}
}
unsafe void* QtyToBuf(byte* buf, UInt32 qty)
{
*buf++ = (byte)qty;
*buf++ = (byte)(qty >> 8);
*buf++ = (byte)(qty >> 16);
*buf++ = (byte)(qty >> 24);
return (buf);
}
}
}
unsafe void* QtyToBuf(char* buf, UInt32 qty)
{
*buf++ =(char) qty;
*buf++ = (char)(qty >> 8);
*buf++ = (char)(qty >> 16);
*buf++ = (char)(qty >> 24);
return (buf);
}