mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: remove redundant parenthesis in the complex infix expr (#17873)
This commit is contained in:
@@ -163,7 +163,7 @@ fn parser(s string) (ParserState, PrepNumber) {
|
||||
}
|
||||
|
||||
// read mantissa decimals
|
||||
if (i < s.len) && (s[i] == `.`) {
|
||||
if i < s.len && s[i] == `.` {
|
||||
i++
|
||||
for i < s.len && s[i].is_digit() {
|
||||
if digx < strconv.digits {
|
||||
@@ -177,7 +177,7 @@ fn parser(s string) (ParserState, PrepNumber) {
|
||||
}
|
||||
|
||||
// read exponent
|
||||
if (i < s.len) && ((s[i] == `e`) || (s[i] == `E`)) {
|
||||
if i < s.len && (s[i] == `e` || s[i] == `E`) {
|
||||
i++
|
||||
if i < s.len {
|
||||
// esponent sign
|
||||
|
||||
@@ -233,8 +233,8 @@ fn underscore_ok(s string) bool {
|
||||
}
|
||||
// Optional base prefix.
|
||||
mut hex := false
|
||||
if (s.len - i >= 2) && (s[i] == `0`) && (((s[i + 1] | 32) == `b`)
|
||||
|| ((s[i + 1] | 32) == `o`) || ((s[i + 1] | 32) == `x`)) {
|
||||
if s.len - i >= 2 && s[i] == `0` && ((s[i + 1] | 32) == `b`
|
||||
|| (s[i + 1] | 32) == `o` || (s[i + 1] | 32) == `x`) {
|
||||
saw = `0` // base prefix counts as a digit for "underscore as digit separator"
|
||||
hex = (s[i + 1] | 32) == `x`
|
||||
i += 2
|
||||
@@ -242,7 +242,7 @@ fn underscore_ok(s string) bool {
|
||||
// Number proper.
|
||||
for ; i < s.len; i++ {
|
||||
// Digits are always okay.
|
||||
if (`0` <= s[i] && s[i] <= `9`) || ((hex && `a` <= (s[i] | 32)) && ((s[i] | 32) <= `f`)) {
|
||||
if (`0` <= s[i] && s[i] <= `9`) || ((hex && `a` <= (s[i] | 32)) && (s[i] | 32) <= `f`) {
|
||||
saw = `0`
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ fn f32_to_decimal(mant u32, exp u32) Dec32 {
|
||||
// General case, which happens rarely (~4.0%).
|
||||
for vp / 10 > vm / 10 {
|
||||
vm_is_trailing_zeros = vm_is_trailing_zeros && (vm % 10) == 0
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && (last_removed_digit == 0)
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0
|
||||
last_removed_digit = u8(vr % 10)
|
||||
vr /= 10
|
||||
vp /= 10
|
||||
@@ -278,7 +278,7 @@ fn f32_to_decimal(mant u32, exp u32) Dec32 {
|
||||
}
|
||||
if vm_is_trailing_zeros {
|
||||
for vm % 10 == 0 {
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && (last_removed_digit == 0)
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0
|
||||
last_removed_digit = u8(vr % 10)
|
||||
vr /= 10
|
||||
vp /= 10
|
||||
@@ -286,7 +286,7 @@ fn f32_to_decimal(mant u32, exp u32) Dec32 {
|
||||
removed++
|
||||
}
|
||||
}
|
||||
if vr_is_trailing_zeros && (last_removed_digit == 5) && (vr % 2) == 0 {
|
||||
if vr_is_trailing_zeros && last_removed_digit == 5 && (vr % 2) == 0 {
|
||||
// Round even if the exact number is .....50..0.
|
||||
last_removed_digit = 4
|
||||
}
|
||||
@@ -335,7 +335,7 @@ pub fn f32_to_str(f f32, n_digit int) string {
|
||||
// println("${neg} ${mant} e ${exp-bias32}")
|
||||
|
||||
// Exit early for easy cases.
|
||||
if (exp == strconv.maxexp32) || (exp == 0 && mant == 0) {
|
||||
if exp == strconv.maxexp32 || (exp == 0 && mant == 0) {
|
||||
return get_string_special(neg, exp == 0, mant == 0)
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ pub fn f32_to_str_pad(f f32, n_digit int) string {
|
||||
// println("${neg} ${mant} e ${exp-bias32}")
|
||||
|
||||
// Exit early for easy cases.
|
||||
if (exp == strconv.maxexp32) || (exp == 0 && mant == 0) {
|
||||
if exp == strconv.maxexp32 || (exp == 0 && mant == 0) {
|
||||
return get_string_special(neg, exp == 0, mant == 0)
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ fn f64_to_decimal(mant u64, exp u64) Dec64 {
|
||||
vr_div_10 := vr / 10
|
||||
vr_mod_10 := vr % 10
|
||||
vm_is_trailing_zeros = vm_is_trailing_zeros && vm_mod_10 == 0
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && (last_removed_digit == 0)
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0
|
||||
last_removed_digit = u8(vr_mod_10)
|
||||
vr = vr_div_10
|
||||
vp = vp_div_10
|
||||
@@ -275,7 +275,7 @@ fn f64_to_decimal(mant u64, exp u64) Dec64 {
|
||||
vp_div_10 := vp / 10
|
||||
vr_div_10 := vr / 10
|
||||
vr_mod_10 := vr % 10
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && (last_removed_digit == 0)
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0
|
||||
last_removed_digit = u8(vr_mod_10)
|
||||
vr = vr_div_10
|
||||
vp = vp_div_10
|
||||
@@ -283,7 +283,7 @@ fn f64_to_decimal(mant u64, exp u64) Dec64 {
|
||||
removed++
|
||||
}
|
||||
}
|
||||
if vr_is_trailing_zeros && (last_removed_digit == 5) && (vr % 2) == 0 {
|
||||
if vr_is_trailing_zeros && last_removed_digit == 5 && (vr % 2) == 0 {
|
||||
// Round even if the exact number is .....50..0.
|
||||
last_removed_digit = 4
|
||||
}
|
||||
@@ -343,7 +343,7 @@ pub fn f64_to_str(f f64, n_digit int) string {
|
||||
// println("s:${neg} mant:${mant} exp:${exp} float:${f} byte:${u1.u:016lx}")
|
||||
|
||||
// Exit early for easy cases.
|
||||
if (exp == maxexp64) || (exp == 0 && mant == 0) {
|
||||
if exp == maxexp64 || (exp == 0 && mant == 0) {
|
||||
return get_string_special(neg, exp == 0, mant == 0)
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ pub fn f64_to_str_pad(f f64, n_digit int) string {
|
||||
// println("s:${neg} mant:${mant} exp:${exp} float:${f} byte:${u1.u:016lx}")
|
||||
|
||||
// Exit early for easy cases.
|
||||
if (exp == maxexp64) || (exp == 0 && mant == 0) {
|
||||
if exp == maxexp64 || (exp == 0 && mant == 0) {
|
||||
return get_string_special(neg, exp == 0, mant == 0)
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ fn f64_to_decimal(mant u64, exp u64) Dec64 {
|
||||
vr_div_10 := vr / 10
|
||||
vr_mod_10 := vr % 10
|
||||
vm_is_trailing_zeros = vm_is_trailing_zeros && vm_mod_10 == 0
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && (last_removed_digit == 0)
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0
|
||||
last_removed_digit = u8(vr_mod_10)
|
||||
vr = vr_div_10
|
||||
vp = vp_div_10
|
||||
@@ -260,7 +260,7 @@ fn f64_to_decimal(mant u64, exp u64) Dec64 {
|
||||
vp_div_10 := vp / 10
|
||||
vr_div_10 := vr / 10
|
||||
vr_mod_10 := vr % 10
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && (last_removed_digit == 0)
|
||||
vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0
|
||||
last_removed_digit = u8(vr_mod_10)
|
||||
vr = vr_div_10
|
||||
vp = vp_div_10
|
||||
@@ -268,7 +268,7 @@ fn f64_to_decimal(mant u64, exp u64) Dec64 {
|
||||
removed++
|
||||
}
|
||||
}
|
||||
if vr_is_trailing_zeros && (last_removed_digit == 5) && (vr % 2) == 0 {
|
||||
if vr_is_trailing_zeros && last_removed_digit == 5 && (vr % 2) == 0 {
|
||||
// Round even if the exact number is .....50..0.
|
||||
last_removed_digit = 4
|
||||
}
|
||||
@@ -325,7 +325,7 @@ pub fn f64_to_str(f f64, n_digit int) string {
|
||||
// println("s:${neg} mant:${mant} exp:${exp} float:${f} byte:${u1.u:016lx}")
|
||||
|
||||
// Exit early for easy cases.
|
||||
if (exp == maxexp64) || (exp == 0 && mant == 0) {
|
||||
if exp == maxexp64 || (exp == 0 && mant == 0) {
|
||||
return get_string_special(neg, exp == 0, mant == 0)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user