You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-31Lines changed: 35 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,23 @@
1
1
[](https://ci.appveyor.com/project/angularsen/unitsnet)[](https://gitter.im/UnitsNet/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
2
[](https://flattr.com/submit/auto?fid=g37dpx&url=https://github.com/angularsen/UnitsNet/&title=Units.NET&language=en-US&tags=github&category=software)
3
3
4
-
Units.NET
5
-
===
6
4
7
-
Everyone have written their share of trivial conversions - or less obvious ones where you need to Google that magic constant.
5
+
## Units.NET
8
6
9
-
Stop littering your code with unnecessary calculations. Units.NET gives you all the common units of measurement and the conversions between them. It is light-weight, well-tested and portable.
7
+
Everyone have written their share of trivial conversions - or less obvious ones where you need to Google that magic constant.
10
8
9
+
Stop littering your code with unnecessary calculations, Units.NET gives you all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested.
11
10
12
-
Installing
13
-
---
14
-
Run the following command in the [Package Manager Console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console) or go to the [NuGet site](https://www.nuget.org/packages/UnitsNet/) for the complete relase history.
*[Windows Runtime Component](https://docs.microsoft.com/en-us/windows/uwp/winrt-components/) for UWP apps (JavaScript, C++ or C#)
22
17
23
-
Overview
24
-
---
18
+
19
+
### Overview
20
+
25
21
*[48 quantities with a total of 500+ units](UnitsNet/GeneratedCode/Enums) generated from [JSON](UnitsNet/UnitDefinitions/) by [Powershell scripts](UnitsNet/Scripts)
26
22
*[1000+ unit tests](https://ci.appveyor.com/project/angularsen/unitsnet) on conversions and localizations
27
23
* Immutable structs that implement `Equatable`, `IComparable`
@@ -37,8 +33,16 @@ Overview
37
33
*[Continuous integration](#ci) posts status reports to pull requests and commits
38
34
*[Who are using this?](#who-are-using)
39
35
40
-
<aname="static-typing"></a>Static Typing
41
-
---
36
+
37
+
### Installing
38
+
39
+
Run the following command in the [Package Manager Console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console) or go to the [NuGet site](https://www.nuget.org/packages/UnitsNet/) for the complete relase history.
Forceweight=80.Kilograms() *stdGravity; // 80 kilograms-force or 784.532 newtons
86
90
```
87
91
88
-
<aname="culture"></a>Culture and Localization
89
-
---
92
+
### <aname="culture"></a>Culture and Localization
93
+
90
94
The culture for abbreviations defaults to Thread.CurrentUICulture and falls back to US English if not defined. Thread.CurrentCulture affects number formatting unless a custom culture is specified. The relevant methods are:
<aname="example-app"></a>Example: Creating a unit converter app
121
-
---
124
+
### <aname="example-app"></a>Example: Creating a unit converter app
125
+
122
126
*TODO: Add actual sample app and link to it here with screenshot. See [#274](https://github.com/angularsen/UnitsNet/issues/274) for details.*
123
127
124
128
This example shows how you can create a dynamic unit converter, where the user selects the quantity to convert, such as `Length` or `Mass`, then selects to convert from `Meter` to `Centimeter` and types in a value for how many meters.
A base unit is chosen for each unit class, represented by a double value (64-bit), and all conversions go via this unit. This means there will always be a small error in both representing other units than the base unit as well as converting between units.
141
145
142
146
Units.NET was intended for convenience and ease of use, not highly accurate conversions, but I am open to suggestions for improvements.
@@ -146,8 +150,8 @@ The tests accept an error up to 1E-5 for most units added so far. Exceptions inc
146
150
For more details, see [Precision](https://github.com/angularsen/UnitsNet/wiki/Precision).
147
151
148
152
149
-
<aname="serialization"></a>Serialization
150
-
---
153
+
### <aname="serialization"></a>Serialization
154
+
151
155
*`UnitsNet.Serialization.JsonNet` ([nuget](https://www.nuget.org/packages/UnitsNet.Serialization.JsonNet), [src](https://github.com/angularsen/UnitsNet/tree/master/UnitsNet.Serialization.JsonNet), [tests](https://github.com/angularsen/UnitsNet/tree/master/UnitsNet.Serialization.JsonNet.Tests)) for JSON.NET
152
156
153
157
**Important!**
@@ -156,8 +160,8 @@ We cannot guarantee backwards compatibility, although we will strive to do that
156
160
The base unit of any unit should be be treated as volatile as we have changed this several times in the history of this library already. Either to reduce precision errors of common units or to simplify code generation. An example is Mass, where the base unit was first Kilogram as this is the SI unit of mass, but in order to use powershell scripts to generate milligrams, nanograms etc. it was easier to choose Gram as the base unit of Mass.
157
161
158
162
159
-
<aname="contribute"></a>Want To Contribute?
160
-
---
163
+
### <aname="contribute"></a>Want To Contribute?
164
+
161
165
This project is still early and many units and conversions are not yet covered. If you are missing something, please help by contributing or [ask for it](https://github.com/angularsen/UnitsNet/issues) by creating an issue.
162
166
163
167
Please read the wiki on [Adding a New Unit](https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit).
@@ -168,15 +172,15 @@ Generally adding a unit involves adding or modifying `UnitsNet\UnitDefinitions\*
168
172
* Do work on branches such as **feature/add-myunit** and **fix/34**
169
173
*[Create a pull request](https://help.github.com/articles/using-pull-requests)
170
174
171
-
<aname="ci"></a>Continuous Integration
172
-
---
175
+
### <aname="ci"></a>Continuous Integration
176
+
173
177
[AppVeyor](https://ci.appveyor.com/project/angularsen/unitsnet) performs the following:
174
178
* Build and test all branches
175
179
* Build and test pull requests, notifies on success or error
176
180
* Deploy nugets on master branch, if nuspec versions changed
177
181
178
-
<aname="who-are-using"></a>Who are Using This?
179
-
---
182
+
### <aname="who-are-using"></a>Who are Using This?
183
+
180
184
It would be awesome to know who are using this library. If you would like your project listed here, [create an issue](https://github.com/angularsen/UnitsNet/issues) or edit the [README.md](https://github.com/angularsen/UnitsNet/edit/master/README.md) and send a pull request. Max logo size is `300x35 pixels` and should be in `.png`, `.gif` or `.jpg` formats.
0 commit comments