Fix C++ floating point literal formatting (#2114)

Found formatting errors with this regex
"([^a-z0-9\.]\.[0-9]|[^a-z0-9\.][0-9]\.[^a-z0-9\.])" and ignored false
positives.

Fixes #2112.
This commit is contained in:
Tyler Veness
2019-11-20 21:48:16 -08:00
committed by Peter Johnson
parent 3d1ca856b2
commit ffa4b907c0
40 changed files with 82 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -181,7 +181,7 @@ void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
if (*status != 0) return;
gyro->center = static_cast<int32_t>(
static_cast<double>(value) / static_cast<double>(count) + .5);
static_cast<double>(value) / static_cast<double>(count) + 0.5);
gyro->offset = static_cast<double>(value) / static_cast<double>(count) -
static_cast<double>(gyro->center);

View File

@@ -103,9 +103,9 @@ void initializeDigital(int32_t* status) {
(kSystemClockTicksPerMicrosecond * 1e3);
pwmSystem->writeConfig_Period(
static_cast<uint16_t>(kDefaultPwmPeriod / loopTime + .5), status);
static_cast<uint16_t>(kDefaultPwmPeriod / loopTime + 0.5), status);
uint16_t minHigh = static_cast<uint16_t>(
(kDefaultPwmCenter - kDefaultPwmStepsDown * loopTime) / loopTime + .5);
(kDefaultPwmCenter - kDefaultPwmStepsDown * loopTime) / loopTime + 0.5);
pwmSystem->writeConfig_MinHigh(minHigh, status);
// Ensure that PWM output values are set to OFF
for (uint8_t pwmIndex = 0; pwmIndex < kNumPWMChannels; pwmIndex++) {

View File

@@ -35,7 +35,7 @@ Encoder::Encoder(HAL_Handle digitalSourceHandleA,
return;
}
m_counter = HAL_kInvalidHandle;
SetMaxPeriod(.5, status);
SetMaxPeriod(0.5, status);
break;
}
case HAL_Encoder_k1X:

View File

@@ -308,54 +308,54 @@ void HAL_GetPDPAllChannelCurrents(HAL_PDPHandle handle, double* currents,
currents[0] = ((static_cast<uint32_t>(pdpStatus.bits.chan1_h8) << 2) |
pdpStatus.bits.chan1_l2) *
.125;
0.125;
currents[1] = ((static_cast<uint32_t>(pdpStatus.bits.chan2_h6) << 4) |
pdpStatus.bits.chan2_l4) *
.125;
0.125;
currents[2] = ((static_cast<uint32_t>(pdpStatus.bits.chan3_h4) << 6) |
pdpStatus.bits.chan3_l6) *
.125;
0.125;
currents[3] = ((static_cast<uint32_t>(pdpStatus.bits.chan4_h2) << 8) |
pdpStatus.bits.chan4_l8) *
.125;
0.125;
currents[4] = ((static_cast<uint32_t>(pdpStatus.bits.chan5_h8) << 2) |
pdpStatus.bits.chan5_l2) *
.125;
0.125;
currents[5] = ((static_cast<uint32_t>(pdpStatus.bits.chan6_h6) << 4) |
pdpStatus.bits.chan6_l4) *
.125;
0.125;
currents[6] = ((static_cast<uint32_t>(pdpStatus2.bits.chan7_h8) << 2) |
pdpStatus2.bits.chan7_l2) *
.125;
0.125;
currents[7] = ((static_cast<uint32_t>(pdpStatus2.bits.chan8_h6) << 4) |
pdpStatus2.bits.chan8_l4) *
.125;
0.125;
currents[8] = ((static_cast<uint32_t>(pdpStatus2.bits.chan9_h4) << 6) |
pdpStatus2.bits.chan9_l6) *
.125;
0.125;
currents[9] = ((static_cast<uint32_t>(pdpStatus2.bits.chan10_h2) << 8) |
pdpStatus2.bits.chan10_l8) *
.125;
0.125;
currents[10] = ((static_cast<uint32_t>(pdpStatus2.bits.chan11_h8) << 2) |
pdpStatus2.bits.chan11_l2) *
.125;
0.125;
currents[11] = ((static_cast<uint32_t>(pdpStatus2.bits.chan12_h6) << 4) |
pdpStatus2.bits.chan12_l4) *
.125;
0.125;
currents[12] = ((static_cast<uint32_t>(pdpStatus3.bits.chan13_h8) << 2) |
pdpStatus3.bits.chan13_l2) *
.125;
0.125;
currents[13] = ((static_cast<uint32_t>(pdpStatus3.bits.chan14_h6) << 4) |
pdpStatus3.bits.chan14_l4) *
.125;
0.125;
currents[14] = ((static_cast<uint32_t>(pdpStatus3.bits.chan15_h4) << 6) |
pdpStatus3.bits.chan15_l6) *
.125;
0.125;
currents[15] = ((static_cast<uint32_t>(pdpStatus3.bits.chan16_h2) << 8) |
pdpStatus3.bits.chan16_l8) *
.125;
0.125;
}
double HAL_GetPDPTotalCurrent(HAL_PDPHandle handle, int32_t* status) {