Skip to content

Commit d7e2909

Browse files
Added some intellisense summaries for the decimal normalizer so it is clearer when to use each version
1 parent b167223 commit d7e2909

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

Packages/Sequence-Unity/Sequence/SequenceSDK/Utils/DecimalNormalizer.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,39 @@ namespace Sequence.Utils
66
{
77
public static class DecimalNormalizer
88
{
9+
/// <summary>
10+
/// Normalize a float value into EVM-readable format
11+
/// </summary>
12+
/// <param name="x"></param>
13+
/// <param name="decimals"></param>
14+
/// <returns></returns>
915
public static string Normalize(float x, int decimals = 18)
1016
{
1117
BigInteger result = NormalizeAsBigInteger(x, decimals);
1218
return result.ToString();
1319
}
1420

21+
/// <summary>
22+
/// Normalize a float value into EVM-readable format
23+
/// </summary>
24+
/// <param name="x"></param>
25+
/// <param name="decimals"></param>
26+
/// <returns></returns>
1527
public static BigInteger NormalizeAsBigInteger(float x, int decimals = 18)
1628
{
1729
x = Math.Abs(x);
1830
double normalized = x * Math.Pow(10, decimals);
1931
BigInteger result = (BigInteger) normalized;
2032
return result;
2133
}
22-
34+
35+
/// <summary>
36+
/// Return the value back into human-readable format
37+
/// Gives a string value - recommended for use in UI or anywhere where precision matters
38+
/// </summary>
39+
/// <param name="x"></param>
40+
/// <param name="decimals"></param>
41+
/// <returns></returns>
2342
public static string ReturnToNormalString(BigInteger x, int decimals = 18)
2443
{
2544
string numberStr = BigInteger.Abs(x).ToString();
@@ -42,11 +61,25 @@ public static string ReturnToNormalString(BigInteger x, int decimals = 18)
4261
return resultStr;
4362
}
4463

64+
/// <summary>
65+
/// Return the value back into human-readable format
66+
/// Gives a float value - recommended for use during gameplay or anywhere where performance matters
67+
/// </summary>
68+
/// <param name="x"></param>
69+
/// <param name="decimals"></param>
70+
/// <returns></returns>
4571
public static float ReturnToNormal(BigInteger x, int decimals = 18)
4672
{
4773
return float.Parse(ReturnToNormalString(x, decimals));
4874
}
4975

76+
/// <summary>
77+
/// Return the value back into human-readable format
78+
/// Gives a decimal value - recommended for use in UI or anywhere where precision matters
79+
/// </summary>
80+
/// <param name="x"></param>
81+
/// <param name="decimals"></param>
82+
/// <returns></returns>
5083
public static decimal ReturnToNormalPrecise(BigInteger x, int decimals = 18)
5184
{
5285
return decimal.Parse(ReturnToNormalString(x, decimals));

Packages/Sequence-Unity/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xyz.0xsequence.waas-unity",
3-
"version": "4.2.3",
3+
"version": "4.2.4",
44
"displayName": "Sequence Embedded Wallet SDK",
55
"description": "A Unity SDK for Sequence APIs",
66
"unity": "2021.3",

0 commit comments

Comments
 (0)