![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
编程语言
文章平均质量分 76
闫建明
既往不恋,纵情向前。
展开
-
ModelBus协议中使用16位传输float浮点数
在ModelBus协议中,每一个数据使用两个字节来表示,可是float浮点数有四个字节,如何把float转换成两个字节的字节流呢?本文参照IEEE754浮点数标准,给出了一个16位的float定义方法,即符号位1位,阶码位5位,尾数位10位,当然这样做,会损失精度,有效位数只有4位。#includeusing namespace std;void FloatToBuf(float num,原创 2014-01-03 23:56:24 · 6478 阅读 · 0 评论 -
C++解析IEEE754中float格式的数据
#includeusing namespace std;void FloatToBuf(float num, unsigned char buf[4]);float BufToFloat(unsigned char buf[4]);int main(){ float f = 639.8f; //待转换的浮点数 int *p = (int *)&f; for(int原创 2014-01-03 23:31:46 · 2599 阅读 · 0 评论 -
大文件分割程序
#include#include#include#includeusing namespace std;int main(){ string path; cout<<"请输入要分隔的文件路径:"; cin>>path; string block; cout<<"请输入每块的文件大小(1G/1M/1K/1B):"; cin>>block; const int block_s原创 2014-05-30 16:20:42 · 600 阅读 · 0 评论 -
C#中重新定义Console实现自动保存输出到文件
class Console{ public static string ReadLine() { return System.Console.ReadLine(); } public static ConsoleKeyInfo ReadKey() { return System.Console.ReadKey();原创 2016-05-25 17:37:36 · 2737 阅读 · 0 评论 -
简易上传文件管理系统
<?phpif(isset($_GET['type'])){ $path="attachment/".date("Ymd"); if($_GET['type']=="0"){ if(!file_exists($path)){ mkdir($path); } if(move_uploaded_file($_FILES["file"]["tmp_name"], $path."/原创 2016-07-12 14:41:04 · 1545 阅读 · 0 评论 -
C#判断文本文件编码是ANSI还是无BOM的UTF8
Encoding GetBytesEncoding(byte[] bs){ int len = bs.Length; if (len >= 3 && bs[0] == 0xEF && bs[1] == 0xBB && bs[2] == 0xBF) { return Encoding.UTF8; } int[] cs = { 7, 5, 4,原创 2016-10-11 23:19:07 · 5286 阅读 · 2 评论 -
C#命名方式转换代码
/// /// 命名方式转换/// public static class NameStyleConvert{ /// /// 从ab_cd到AbCd /// /// 属性名或字段名 /// public static string F_TC(string name) { return Regex.Replace原创 2016-10-25 19:27:52 · 570 阅读 · 0 评论