HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
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
26
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
27
28
class
IMF_EXPORT_TYPE
Rational
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
50
IMF_EXPORT
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
60
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
61
62
#endif
ImfNamespace.h
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition:
ImfNamespace.h:83
Rational::n
int n
Definition:
ImfRational.h:31
n
GLdouble n
Definition:
glcorearb.h:2008
Rational
Definition:
ImfRational.h:28
IMF_EXPORT
#define IMF_EXPORT
Definition:
ImfExport.h:54
x
GLint GLenum GLint x
Definition:
glcorearb.h:409
ImfExport.h
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition:
ImfNamespace.h:80
Rational::Rational
Rational(int n, int d)
Definition:
ImfRational.h:44
IMF_EXPORT_TYPE
#define IMF_EXPORT_TYPE
Definition:
ImfExport.h:57
Rational::Rational
Rational()
Definition:
ImfRational.h:38
Rational::d
unsigned int d
Definition:
ImfRational.h:32
OpenEXR
ImfRational.h
Generated on Sun Nov 17 2024 03:01:37 for HDK by
1.8.6