Skip to content

Commit a9eed87

Browse files
Fix more casts (#778)
1 parent 5e4e13f commit a9eed87

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

example_10/hardware/rrbot.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ hardware_interface::return_type RRBotSystemWithGPIOHardware::read(
197197
unsigned int seed = static_cast<unsigned int>(time(NULL)) + 1;
198198
set_state(
199199
info_.gpios[0].name + "/" + info_.gpios[0].state_interfaces[1].name,
200-
static_cast<float>(rand_r(&seed)));
200+
static_cast<double>(rand_r(&seed)));
201201
seed = static_cast<unsigned int>(time(NULL)) + 2;
202202
set_state(
203203
info_.gpios[0].name + "/" + info_.gpios[0].state_interfaces[2].name,
204-
static_cast<float>(rand_r(&seed)));
204+
static_cast<double>(rand_r(&seed)));
205205

206206
for (const auto & [name, descr] : gpio_state_interfaces_)
207207
{

example_4/hardware/rrbot_system_with_sensor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ hardware_interface::return_type RRBotSystemWithSensorHardware::read(
184184
// Simulate RRBot's sensor data
185185
unsigned int seed = static_cast<unsigned int>(time(NULL)) + i++;
186186
set_state(
187-
name, static_cast<float>(rand_r(&seed)) / (static_cast<float>(RAND_MAX / hw_sensor_change_)));
187+
name,
188+
static_cast<double>(rand_r(&seed)) / (static_cast<double>(RAND_MAX / hw_sensor_change_)));
188189

189190
ss << std::endl << "\t" << get_state(name) << " for sensor '" << name << "'";
190191
}

0 commit comments

Comments
 (0)