| Server IP : 35.154.56.2 / Your IP : 216.73.217.116 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-0-189 6.8.0-1029-aws #31-Ubuntu SMP Wed Apr 23 18:20:04 UTC 2025 aarch64 User : ubuntu ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/include/OpenEXR/ |
Upload File : |
//
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) Contributors to the OpenEXR Project.
//
#ifndef INCLUDED_IMF_RATIONAL_H
#define INCLUDED_IMF_RATIONAL_H
#include "ImfExport.h"
#include "ImfNamespace.h"
//-----------------------------------------------------------------------------
//
// Rational numbers
//
// A rational number is represented as pair of integers, n and d.
// The value of of the rational number is
//
// n/d for d > 0
// positive infinity for n > 0, d == 0
// negative infinity for n < 0, d == 0
// not a number (NaN) for n == 0, d == 0
//
//-----------------------------------------------------------------------------
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
class IMF_EXPORT_TYPE Rational
{
public:
int n; // numerator
unsigned int d; // denominator
//----------------------------------------
// Default constructor, sets value to zero
//----------------------------------------
Rational (): n (0), d (1) {}
//-------------------------------------
// Constructor, explicitly sets n and d
//-------------------------------------
Rational (int n, int d): n (n), d (d) {}
//----------------------------
// Constructor, approximates x
//----------------------------
IMF_EXPORT
explicit Rational (double x);
//---------------------------------
// Approximate conversion to double
//---------------------------------
operator double () const {return double (n) / double (d);}
};
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
#endif