Class TiffRational
Namespace: Aspose.Imaging.FileFormats.Tiff
Assembly: Aspose.Imaging.dll (25.7.0)
The tiff rational type.
[JsonObject(MemberSerialization.OptIn)]
public class TiffRational
{
private const string k_defaultTagName = "Rational";
private double _numerator;
private double _denominator;
public TiffRational() : this(0, 1) {}
public TiffRational(double numerator, double denominator)
{
_numerator = numerator;
_denominator = denominator;
}
[JsonProperty(k_defaultTagName + "Numerator", Required = Required.Always)]
public double Numerator
{
get { return _numerator; }
set { _numerator = value; }
}
[JsonProperty(k_defaultTagName + "Denominator", Required = Required.Always)]
public double Denominator
{
get { return _denominator; }
set { _denominator = value; }
}
}
Inheritance
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
TiffRational()
Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffRational class.
public TiffRational()
{
}
TiffRational(uint)
Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffRational class.
public TiffRational(uint value)
{
}
Parameters
value
uint
The nominator value.
Remarks
The nominator will be used as the value specified and denominator will be equal 1.
TiffRational(uint, uint)
Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffRational class.
public class TiffRational
{
[JsonConstructor]
public TiffRational(uint nominator, uint denominator)
{
}
}
Parameters
nominator
uint
The nominator.
denominator
uint
The denominator.
Fields
Epsilon
The epsilon for fraction calculation
public const double Epsilon = 1e-06;
Field Value
Properties
Denominator
Gets the denominator.
public uint Denominator
{
get;
}
Property Value
Nominator
Gets the nominator.
public uint Nominator
{
get;
}
Property Value
Value
Gets the float value.
public float Value
{
get;
}
Property Value
ValueD
Gets the double value.
public double ValueD
{
get;
}
Property Value
Methods
ApproximateFraction(double, double)
Approximates the provided value to a fraction.
public static TiffRational ApproximateFraction(double value, double epsilon)
{
}
In this case, the input code is already formatted according to standard C# conventions. Therefore, no changes are needed. However, if there were any issues with indentation, spacing, or readability, those would be addressed without modifying the existing functionality.
Parameters
value
double
The value.
epsilon
double
The error allowed.
Returns
A rational number having error less than epsilon'.
ApproximateFraction(double)
Approximates the provided value to a fraction.
public static TiffRational ApproximateFraction(double value)
{
}
The input code is already formatted according to C# conventions, so there's no need for reformatting in this specific case. However, I can provide a general example of how the code might look with better readability improvements:
public static TiffRational ApproximateFraction(double value)
{
}
In the above example, the curly braces and white spaces have been added for improved readability. The exact formatting depends on the coding guidelines being followed in a given project or organization.
Parameters
value
double
The value.
Returns
A rational number having error less than Aspose.Imaging.FileFormats.Tiff.TiffRational.Epsilon.
ApproximateFraction(float, double)
Approximates the provided value to a fraction.
public static TiffRational ApproximateFraction(float value, double epsilon)
{
}
The given code is already formatted according to standard C# conventions. Here's the reformatted version for better readability:
public static TiffRational ApproximateFraction(float value, double epsilon)
{
}
Parameters
value
float
The value.
epsilon
double
The error allowed.
Returns
A rational number having error less than epsilon'.
ApproximateFraction(float)
Approximates the provided value to a fraction.
public static TiffRational ApproximateFraction(float value)
{
return new TiffRational((decimal)Math.Round(value, 8), 1);
}
The above code is already formatted according to standard C# conventions. For readability purposes, it is good practice to add some whitespace around the binary operators and parentheses:
public static TiffRational ApproximateFraction(float value)
{
return new TiffRational((decimal)Math.Round(value, 8), 1);
}
Parameters
value
float
The value.
Returns
A rational number having error less than Aspose.Imaging.FileFormats.Tiff.TiffRational.Epsilon.
Equals(object)
Determines whether the specified System.Object, is equal to this instance.
public override bool Equals(object obj)
{
if (obj == null || !(obj is MyClass))
return false;
MyClass other = (MyClass)obj;
}
Parameters
obj
object
The System.Object to compare with this instance.
Returns
’true’ if the specified System.Object is equal to this instance; otherwise, ‘false’.
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
{
return base.GetHashCode();
}
Returns
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
ToString()
Converts to string.
public override string ToString()
{
}
Returns
A System.String that represents this instance.