YARP
Yet Another Robot Platform
NetFloat64.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/NetFloat64.h>
11 
12 #ifndef YARP_LITTLE_ENDIAN
13 
14 using namespace yarp;
15 using namespace yarp::os;
16 
17 
18 double NetFloat64::swap(double x) const
19 {
20  UnionNetFloat64 in, out;
21  in.d = x;
22  for (int i = 0; i < 8; i++) {
23  out.c[i] = in.c[7 - i];
24  }
25  return out.d;
26 }
27 
28 RawNetFloat64 NetFloat64::get() const
29 {
30  return (double)swap((double)raw_value);
31 }
32 
33 void NetFloat64::set(RawNetFloat64 v)
34 {
35  raw_value = (double)swap((double)v);
36 }
37 
39 {
40 }
41 
42 NetFloat64::NetFloat64(RawNetFloat64 val)
43 {
44  set(val);
45 }
46 
47 NetFloat64::operator RawNetFloat64() const
48 {
49  return get();
50 }
51 
52 RawNetFloat64 NetFloat64::operator+(RawNetFloat64 v) const
53 {
54  return get() + v;
55 }
56 
57 RawNetFloat64 NetFloat64::operator-(RawNetFloat64 v) const
58 {
59  return get() - v;
60 }
61 
62 RawNetFloat64 NetFloat64::operator*(RawNetFloat64 v) const
63 {
64  return get() * v;
65 }
66 
67 RawNetFloat64 NetFloat64::operator/(RawNetFloat64 v) const
68 {
69  return get() / v;
70 }
71 
72 void NetFloat64::operator+=(RawNetFloat64 v)
73 {
74  set(get() + v);
75 }
76 
77 void NetFloat64::operator-=(RawNetFloat64 v)
78 {
79  set(get() - v);
80 }
81 
82 void NetFloat64::operator*=(RawNetFloat64 v)
83 {
84  set(get() * v);
85 }
86 
87 void NetFloat64::operator/=(RawNetFloat64 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
NetFloat64.h
operator/
Vector operator/(const Vector &a, const Vector &b)
Vector-vector element-wise division operator (defined in Math.h).
Definition: math.cpp:250
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
yarp::os::NetFloat64
yarp::conf::float64_t NetFloat64
Definition of the NetFloat64 type.
Definition: NetFloat64.h:45