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