jaulib v1.3.0
Jau Support Library (C++, Java, ..)
float_si_types.hpp
Go to the documentation of this file.
1/*
2 * Author: Svenson Han Gothel <shg@jausoft.com>
3 * Copyright (c) 2020-2024 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef JAU_FLOAT_SI_TYPES_HPP_
26#define JAU_FLOAT_SI_TYPES_HPP_
27
28namespace jau {
29
30 /** \addtogroup Floats
31 *
32 * @{
33 */
34
35 /** Time in fractions of seconds using float. */
36 typedef float si_timef32_t;
37 /** Length in fractions of meter using float. */
38 typedef float si_lengthf32_t;
39 /** Mass in fractions of kilograms using float. */
40 typedef float si_massf32_t;
41 /** Speed in fractions of meter/seconds using float. */
42 typedef float si_speedf32_t;
43
44 namespace float_literals {
45 constexpr si_timef32_t operator ""_h(unsigned long long int __v) { return (si_timef32_t)__v*3600.0f; }
46 constexpr si_timef32_t operator ""_min(unsigned long long int __v) { return (si_timef32_t)__v*60.0f; }
47 constexpr si_timef32_t operator ""_s(unsigned long long int __v) { return (si_timef32_t)__v; }
48 constexpr si_timef32_t operator ""_ms(unsigned long long int __v) { return (si_timef32_t)__v/1000.0f; }
49
50 constexpr si_lengthf32_t operator ""_km(unsigned long long int __v) { return (si_lengthf32_t)__v*1000.0f; }
51 constexpr si_lengthf32_t operator ""_m(unsigned long long int __v) { return (si_lengthf32_t)__v; }
52 constexpr si_lengthf32_t operator ""_cm(unsigned long long int __v) { return (si_lengthf32_t)__v/100.0f; }
53 constexpr si_lengthf32_t operator ""_mm(unsigned long long int __v) { return (si_lengthf32_t)__v/1000.0f; }
54
55 constexpr si_massf32_t operator ""_kg(unsigned long long int __v) { return (si_massf32_t)__v; }
56 constexpr si_massf32_t operator ""_g(unsigned long long int __v) { return (si_massf32_t)__v/1000.0f; }
57
58 constexpr si_speedf32_t operator ""_m_s(unsigned long long int __v) { return (si_speedf32_t)__v; }
59 constexpr si_speedf32_t operator ""_km_h(unsigned long long int __v) { return (si_speedf32_t)__v / 3.6f; }
60 } // float_literals
61
62 /**@}*/
63
64} // namespace jau
65
66#endif /* JAU_FLOAT_SI_TYPES_HPP_ */
float si_lengthf32_t
Length in fractions of meter using float.
float si_massf32_t
Mass in fractions of kilograms using float.
float si_speedf32_t
Speed in fractions of meter/seconds using float.
float si_timef32_t
Time in fractions of seconds using float.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition: backtrace.hpp:32