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
28 public double Weight => 0.5;
29
36 public bool TryConvert(object Value, out object Result)
37 {
38 if (Value is BigInteger i)
39 {
40 double d = (double)i;
41 if ((BigInteger)d == i)
42 {
43 Result = d;
44 return true;
45 }
46 }
47
48 Result = null;
49 return false;
50 }
51
59 public bool TryConvertToElement(object Value, out IElement Result)
60 {
61 if (Value is BigInteger i)
62 {
63 double d = (double)i;
64 if ((BigInteger)d == i)
65 {
66 Result = new DoubleNumber(d);
67 return true;
68 }
69 }
70
71 Result = null;
72 return false;
73 }
74
82 public IElement ConvertToElement(object Value)
83 {
84 if (Value is BigInteger i)
85 {
86 double d = (double)i;
87 if ((BigInteger)d == i)
88 return new DoubleNumber(d);
89 else
90 return null;
91 }
92 else
93 throw new ArgumentException("Expected BigInteger value.", nameof(Value));
94 }
95 }
96}
Converts a BigInteger to a double number, if possible.
Type From
Converter converts objects of this type.
Type To
Converter converts objects to this type.
bool TryConvertToElement(object Value, out IElement Result)
Converts the object in Value to an object of type To, encapsulated in an IElement.
double Weight
Weight of the converter. An estimate of how well the converter performs, or how much information is r...
bool TryConvert(object Value, out object Result)
Converts the object in Value to an object of type To.
IElement ConvertToElement(object Value)
Converts the object in Value to an object of type To, encapsulated in an IElement.
Basic interface for all types of elements.
Definition: IElement.cs:21
Converts an object of one type to an object of another type.