Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BigIntegerToDouble.cs
1using System;
2using System.Numerics;
5
7{
12 {
16 public Type From => typeof(BigInteger);
17
21 public Type To => typeof(double);
22
29 public object Convert(object Value)
30 {
31 if (Value is BigInteger i)
32 {
33 double d = (double)i;
34 if (((BigInteger)d) == i)
35 return d;
36 else
37 return null;
38 }
39 else
40 throw new ArgumentException("Expected BigInteger value.", nameof(Value));
41 }
42
50 public IElement ConvertToElement(object Value)
51 {
52 if (Value is BigInteger i)
53 {
54 double d = (double)i;
55 if (((BigInteger)d) == i)
56 return new DoubleNumber(d);
57 else
58 return null;
59 }
60 else
61 throw new ArgumentException("Expected BigInteger value.", nameof(Value));
62 }
63 }
64}
Converts a BigInteger to a double number, if possible.
Type From
Converter converts objects of this type.
IElement ConvertToElement(object Value)
Converts the object in Value to an object of type To, encapsulated in an IElement.
Type To
Converter converts objects to this type.
object Convert(object Value)
Converts the object in Value to an object of type To.
Basic interface for all types of elements.
Definition: IElement.cs:20
Converts an object of one type to an object of another type.