Skip to content

Commit

Permalink
Changed use of 65535 literal to UInt16.max
Browse files Browse the repository at this point in the history
  • Loading branch information
woolseyj authored Jul 28, 2018
1 parent 7a04af1 commit 0528565
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/MPU-6050.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MPU6050{
var rv = UInt16(i2c.readByte(address, command: 0x3B)) << 8
rv |= UInt16(i2c.readByte(address, command: 0x3C))
if (rv >= 0x8000) {
return -(Int((65535 - rv) + 1))
return -(Int((UInt16.max - rv) + 1))
} else {
return Int(rv)
}
Expand All @@ -49,7 +49,7 @@ public class MPU6050{
var rv = UInt16(i2c.readByte(address, command: 0x3D)) << 8
rv |= UInt16(i2c.readByte(address, command: 0x3E))
if (rv >= 0x8000) {
return -(Int((65535 - rv) + 1))
return -(Int((UInt16.max - rv) + 1))
} else {
return Int(rv)
}
Expand All @@ -59,7 +59,7 @@ public class MPU6050{
var rv = UInt16(i2c.readByte(address, command: 0x3F)) << 8
rv |= UInt16(i2c.readByte(address, command: 0x40))
if (rv >= 0x8000) {
return -(Int((65535 - rv) + 1))
return -(Int((UInt16.max - rv) + 1))
} else {
return Int(rv)
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public class MPU6050{
var rv = UInt16(i2c.readByte(address, command: 0x43)) << 8
rv |= UInt16(i2c.readByte(address, command: 0x44))
if (rv >= 0x8000) {
return -(Int((65535 - rv) + 1))
return -(Int((UInt16.max - rv) + 1))
} else {
return Int(rv)
}
Expand All @@ -100,7 +100,7 @@ public class MPU6050{
var rv = UInt16(i2c.readByte(address, command: 0x45)) << 8
rv |= UInt16(i2c.readByte(address, command: 0x46))
if (rv >= 0x8000) {
return -(Int((65535 - rv) + 1))
return -(Int((UInt16.max - rv) + 1))
} else {
return Int(rv)
}
Expand All @@ -110,7 +110,7 @@ public class MPU6050{
var rv = UInt16(i2c.readByte(address, command: 0x47)) << 8
rv |= UInt16(i2c.readByte(address, command: 0x48))
if (rv >= 0x8000) {
return -(Int((65535 - rv) + 1))
return -(Int((UInt16.max - rv) + 1))
} else {
return Int(rv)
}
Expand Down

0 comments on commit 0528565

Please sign in to comment.