1 /*****************************************************************************/
2 // Copyright 2006 Adobe Systems Incorporated
3 // All Rights Reserved.
4 //
5 // NOTICE:  Adobe permits you to use, modify, and distribute this file in
6 // accordance with the terms of the Adobe license agreement accompanying it.
7 /*****************************************************************************/
8 
9 /* $Id: //mondo/dng_sdk_1_2/dng_sdk/source/dng_rational.h#1 $ */
10 /* $DateTime: 2008/03/09 14:29:54 $ */
11 /* $Change: 431850 $ */
12 /* $Author: tknoll $ */
13 
14 /*****************************************************************************/
15 
16 #ifndef __dng_rational__
17 #define __dng_rational__
18 
19 /*****************************************************************************/
20 
21 #include "dng_types.h"
22 
23 /*****************************************************************************/
24 
25 class dng_srational
26 	{
27 
28 	public:
29 
30 		int32 n;		// Numerator
31 		int32 d;		// Denominator
32 
33 	public:
34 
dng_srational()35 		dng_srational ()
36 			:	n (0)
37 			,	d (0)
38 			{
39 			}
40 
dng_srational(int32 nn,int32 dd)41 		dng_srational (int32 nn, int32 dd)
42 			:	n (nn)
43 			,	d (dd)
44 			{
45 			}
46 
Clear()47 		void Clear ()
48 			{
49 			n = 0;
50 			d = 0;
51 			}
52 
IsValid()53 		bool IsValid () const
54 			{
55 			return d != 0;
56 			}
57 
NotValid()58 		bool NotValid () const
59 			{
60 			return !IsValid ();
61 			}
62 
63 		real64 As_real64 () const;
64 
65 		void Set_real64 (real64 x, int32 dd = 0);
66 
67 		void ReduceByFactor (int32 factor);
68 
69 	};
70 
71 /*****************************************************************************/
72 
73 class dng_urational
74 	{
75 
76 	public:
77 
78 		uint32 n;		// Numerator
79 		uint32 d;		// Denominator
80 
81 	public:
82 
dng_urational()83 		dng_urational ()
84 			:	n (0)
85 			,	d (0)
86 			{
87 			}
88 
dng_urational(uint32 nn,uint32 dd)89 		dng_urational (uint32 nn, uint32 dd)
90 			:	n (nn)
91 			,	d (dd)
92 			{
93 			}
94 
Clear()95 		void Clear ()
96 			{
97 			n = 0;
98 			d = 0;
99 			}
100 
IsValid()101 		bool IsValid () const
102 			{
103 			return d != 0;
104 			}
105 
NotValid()106 		bool NotValid () const
107 			{
108 			return !IsValid ();
109 			}
110 
111 		real64 As_real64 () const;
112 
113 		void Set_real64 (real64 x, uint32 dd = 0);
114 
115 		void ReduceByFactor (uint32 factor);
116 
117 	};
118 
119 /*****************************************************************************/
120 
121 #endif
122 
123 /*****************************************************************************/
124