HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfRational.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef INCLUDED_IMF_RATIONAL_H
7 #define INCLUDED_IMF_RATIONAL_H
8 
9 #include "ImfExport.h"
10 #include "ImfNamespace.h"
11 
12 //-----------------------------------------------------------------------------
13 //
14 // Rational numbers
15 //
16 // A rational number is represented as pair of integers, n and d.
17 // The value of of the rational number is
18 //
19 // n/d for d > 0
20 // positive infinity for n > 0, d == 0
21 // negative infinity for n < 0, d == 0
22 // not a number (NaN) for n == 0, d == 0
23 //
24 //-----------------------------------------------------------------------------
25 
27 
29 {
30 public:
31  int n; // numerator
32  unsigned int d; // denominator
33 
34  //----------------------------------------
35  // Default constructor, sets value to zero
36  //----------------------------------------
37 
38  Rational () : n (0), d (1) {}
39 
40  //-------------------------------------
41  // Constructor, explicitly sets n and d
42  //-------------------------------------
43 
44  Rational (int n, int d) : n (n), d (d) {}
45 
46  //----------------------------
47  // Constructor, approximates x
48  //----------------------------
49 
51  explicit Rational (double x);
52 
53  //---------------------------------
54  // Approximate conversion to double
55  //---------------------------------
56 
57  operator double () const { return double (n) / double (d); }
58 };
59 
61 
62 #endif
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:83
GLdouble n
Definition: glcorearb.h:2008
#define IMF_EXPORT
Definition: ImfExport.h:54
GLint GLenum GLint x
Definition: glcorearb.h:409
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:80
Rational(int n, int d)
Definition: ImfRational.h:44
#define IMF_EXPORT_TYPE
Definition: ImfExport.h:57
unsigned int d
Definition: ImfRational.h:32