Debian Codegraph @

src/atlas/util/MicroDeg.h

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #pragma once
12
13 #include <cassert>
14
15 namespace atlas {
16 namespace util {
17
18 inline int microdeg(const double& deg) {
19 assert(deg < 2145.); // Since INT_MAX == 2147483647
20 assert(deg > -2145.); // Since INT_MIN == –2147483648
21 return static_cast<int>(deg < 0 ? deg * 1.e6 - 0.5 : deg * 1.e6 + 0.5);
22 }
23
24 } // namespace util
25 } // namespace atlas