Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DoubleToInt8.cs
1using System;
4
6{
11 {
15 public Type From => typeof(double);
16
20 public Type To => typeof(sbyte);
21
27 public double Weight => 0.5;
28
35 public bool TryConvert(object Value, out object Result)
36 {
37 if (Value is double d && d >= sbyte.MinValue && d <= sbyte.MaxValue && Math.Round(d) == d)
38 {
39 Result = (sbyte)d;
40 return true;
41 }
42 else
43 {
44 Result = null;
45 return false;
46 }
47 }
48
56 public bool TryConvertToElement(object Value, out IElement Result)
57 {
58 if (Value is double d && d >= sbyte.MinValue && d <= sbyte.MaxValue && Math.Round(d) == d)
59 {
60 Result = new ObjectValue((sbyte)d);
61 return true;
62 }
63 else
64 {
65 Result = null;
66 return false;
67 }
68 }
69 }
70}
Converts double numbers to 8-bit integer values.
Definition: DoubleToInt8.cs:11
bool TryConvertToElement(object Value, out IElement Result)
Converts the object in Value to an object of type To, encapsulated in an IElement.
Definition: DoubleToInt8.cs:56
double Weight
Weight of the converter. An estimate of how well the converter performs, or how much information is r...
Definition: DoubleToInt8.cs:27
Type From
Converts double numbers to 8-bit integer values.
Definition: DoubleToInt8.cs:15
bool TryConvert(object Value, out object Result)
Converts the object in Value to an object of type To.
Definition: DoubleToInt8.cs:35
Type To
Converter converts objects to this type.
Definition: DoubleToInt8.cs:20
Basic interface for all types of elements.
Definition: IElement.cs:21
Converts an object of one type to an object of another type.