Skip to content

Commit

Permalink
Merge pull request #5 from neo-project/master
Browse files Browse the repository at this point in the history
UpdatePreview5
  • Loading branch information
Ashuaidehao authored Feb 3, 2021
2 parents 4abe12f + 604541c commit c80b546
Show file tree
Hide file tree
Showing 220 changed files with 5,370 additions and 7,585 deletions.
29 changes: 29 additions & 0 deletions src/neo/BigDecimal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,41 @@ public struct BigDecimal
public byte Decimals => decimals;
public int Sign => value.Sign;

/// <summary>
/// Create BigDecimal from BigInteger
/// </summary>
/// <param name="value">Value</param>
/// <param name="decimals">Decimals</param>
public BigDecimal(BigInteger value, byte decimals)
{
this.value = value;
this.decimals = decimals;
}

/// <summary>
/// Create BigDecimal from decimal
/// </summary>
/// <param name="value">Value</param>
public unsafe BigDecimal(decimal value)
{
ReadOnlySpan<byte> buffer = new ReadOnlySpan<byte>(&value, sizeof(decimal));
this.decimals = buffer[14];
this.value = new BigInteger(decimal.Multiply((decimal)Math.Pow(10, decimals), value));
}

/// <summary>
/// Create BigDecimal from decimal
/// </summary>
/// <param name="value">Value</param>
/// <param name="decimals">Decimals</param>
public unsafe BigDecimal(decimal value, byte decimals)
{
ReadOnlySpan<byte> buffer = new ReadOnlySpan<byte>(&value, sizeof(decimal));
if (buffer[14] > decimals) throw new ArgumentException(null, nameof(value));
this.value = new BigInteger(decimal.Multiply((decimal)Math.Pow(10, decimals), value));
this.decimals = decimals;
}

public BigDecimal ChangeDecimals(byte decimals)
{
if (this.decimals == decimals) return this;
Expand Down
44 changes: 0 additions & 44 deletions src/neo/Consensus/ChangeView.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/neo/Consensus/ChangeViewReason.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/neo/Consensus/Commit.cs

This file was deleted.

Loading

0 comments on commit c80b546

Please sign in to comment.