当前位置:网站首页>在代码中使用度量单位,从而生活更美好
在代码中使用度量单位,从而生活更美好
2022-07-04 03:55:00 【dotNET跨平台】
在我们的应用软件中,涉及到物理化学计算时,只有 Frink 、F#、Modelica 少数语言变量是自带单位的,大部分语言变量仅包含数值,单位转换需要在变量进行公式计算之前完成,计算后再把结果单位转换为输出单位,单位转换主要通过若干常数实现。这带来了两个问题:
大量常数降低代码可读性和维护性;
计算精度难以保障。
UnitsNet 用具有单位的变量替代double,支持单位的自动转换,并(部分)支持不同单位的乘除计算。使用UnitsNet 写公式计算代码,可以避免直接的单位转换,使程序的调用者可以使用任意单位作为输入。在.NET IoT 将 UnitsNet 用于任何传感器在绑定中公开的任何单元。在文档里有明确的设备 API 的约定:https://github.com/dotnet/iot/blob/main/Documentation/Devices-conventions.md
相关参考文章:
理化计算程序必备:CoolProp+UnitsNet:https://blog.csdn.net/xhydongda/article/details/120663619
深入研究 .NET NANOFRAMEWORK 的一年:https://www.nanoframework.net/laurent-ellerbach-a-year-deeply-in-net-nanoframework/
边栏推荐
- 【云原生】那些看起来很牛X,原理却很简单的一行代码
- 旭化成首次参展第五届中国国际进口博览会(5th CIIE)
- EventBridge 在 SaaS 企业集成领域的探索与实践
- B. All Distinct
- RAC delete damaged disk group
- Rhcsa 03 - Basic permissions for documents
- 6-4 vulnerability exploitation SSH banner information acquisition
- Experience sharing of epidemic telecommuting | community essay solicitation
- Modstartblog modern personal blog system v5.2.0 source code download
- 牛客小白月赛49
猜你喜欢
分布式CAP理论
The five pictures tell you: why is there such a big gap between people in the workplace?
Rhcsa 04 - process management
Balloon punching and Boolean operation problems (extremely difficult)
技术管理 - 学习/实践
Application scheme of Puyuan ds1000z series digital oscilloscope in communication principle experiment
[cloud native] those lines of code that look awesome but have a very simple principle
1. Mx6u-alpha development board (LED drive experiment in C language version)
Wechat official account infinite callback authorization system source code
软件设计文档示例模板 - 学习/实践
随机推荐
y55.第三章 Kubernetes从入门到精通 -- HPA控制器及metrics-server(二八)
Touch your hand and bring you a commonjs specification
十字路口通行优先权,十字路口通行规则图解
Unity中RampTex介绍和应用: 溶解特效优化
Y55. Chapter III kubernetes from entry to proficiency -- HPA controller and metrics server (28)
MySQL 索引和事务
Intersection traffic priority, illustration of intersection traffic rules
更优雅地远程操作服务器:Paramiko库的实践
Operation of ES6
A beautiful API document generation tool
Select function variable column name in dplyr of R language
leetcode:1314. Matrix area and [2D prefix and template]
Emlog用户注册插件 价值80元
ADB tools
Redis: hash type data operation command
沃博联结束战略评估,决定保留表现优异的博姿业务
6-5 vulnerability exploitation SSH weak password cracking and utilization
Application scheme of Puyuan ds1000z series digital oscilloscope in communication principle experiment
Niuke Xiaobai monthly race 49
两万字带你掌握多线程