YARP
Yet Another Robot Platform
NetFloat32.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
8
9#ifndef YARP_LITTLE_ENDIAN
10
11using namespace yarp;
12using namespace yarp::os;
13
14
15double NetFloat32::swap(double x) const
16{
17 UnionNetFloat32 in, out;
18 in.d = x;
19 for (int i = 0; i < 4; i++) {
20 out.c[i] = in.c[3 - i];
21 }
22 return out.d;
23}
24
25RawNetFloat32 NetFloat32::get() const
26{
27 return (double)swap((double)raw_value);
28}
29
30void NetFloat32::set(RawNetFloat32 v)
31{
32 raw_value = (double)swap((double)v);
33}
34
36{
37}
38
39NetFloat32::NetFloat32(RawNetFloat32 val)
40{
41 set(val);
42}
43
44NetFloat32::operator RawNetFloat32() const
45{
46 return get();
47}
48
49RawNetFloat32 NetFloat32::operator+(RawNetFloat32 v) const
50{
51 return get() + v;
52}
53
54RawNetFloat32 NetFloat32::operator-(RawNetFloat32 v) const
55{
56 return get() - v;
57}
58
59RawNetFloat32 NetFloat32::operator*(RawNetFloat32 v) const
60{
61 return get() * v;
62}
63
64RawNetFloat32 NetFloat32::operator/(RawNetFloat32 v) const
65{
66 return get() / v;
67}
68
69void NetFloat32::operator+=(RawNetFloat32 v)
70{
71 set(get() + v);
72}
73
74void NetFloat32::operator-=(RawNetFloat32 v)
75{
76 set(get() - v);
77}
78
79void NetFloat32::operator*=(RawNetFloat32 v)
80{
81 set(get() * v);
82}
83
84void NetFloat32::operator/=(RawNetFloat32 v)
85{
86 set(get() / v);
87}
88
89
90#endif // YARP_LITTLE_ENDIAN
Vector operator+(const Vector &a, const double &s)
Mathematical operations.
Definition: math.cpp:27
Vector operator-(const Vector &a, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition: math.cpp:82
Vector operator*(double k, const Vector &b)
Scalar-vector product operator (defined in Math.h).
Definition: math.cpp:143
Vector & operator-=(Vector &a, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition: math.cpp:98
Vector & operator+=(Vector &a, const double &s)
Addition operator between a scalar and a vector (defined in Math.h).
Definition: math.cpp:38
Vector & operator/=(Vector &a, const Vector &b)
Vector-vector element-wise division operator (defined in Math.h).
Definition: math.cpp:266
Vector operator/(const Vector &a, const Vector &b)
Vector-vector element-wise division operator (defined in Math.h).
Definition: math.cpp:260
Vector & operator*=(Vector &a, double k)
Vector-scalar product operator (defined in Math.h).
Definition: math.cpp:154
An interface to the operating system, including Port based communication.
yarp::conf::float32_t NetFloat32
Definition of the NetFloat32 type.
Definition: NetFloat32.h:41
The main, catch-all namespace for YARP.
Definition: dirs.h:16