mirror of
https://github.com/vlang/v.git
synced 2025-09-15 15:32:27 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -1,22 +1,22 @@
|
|||
module big
|
||||
|
||||
pub const zero_int = Integer{
|
||||
digits: []u32{len: 0}
|
||||
signum: 0
|
||||
digits: []u32{len: 0}
|
||||
signum: 0
|
||||
is_const: true
|
||||
}
|
||||
pub const one_int = Integer{
|
||||
digits: [u32(1)]
|
||||
signum: 1
|
||||
digits: [u32(1)]
|
||||
signum: 1
|
||||
is_const: true
|
||||
}
|
||||
pub const two_int = Integer{
|
||||
digits: [u32(2)]
|
||||
signum: 1
|
||||
digits: [u32(2)]
|
||||
signum: 1
|
||||
is_const: true
|
||||
}
|
||||
pub const three_int = Integer{
|
||||
digits: [u32(3)]
|
||||
signum: 1
|
||||
digits: [u32(3)]
|
||||
signum: 1
|
||||
is_const: true
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ fn (mut x Integer) free() {
|
|||
|
||||
fn (x Integer) clone() Integer {
|
||||
return Integer{
|
||||
digits: x.digits.clone()
|
||||
signum: x.signum
|
||||
digits: x.digits.clone()
|
||||
signum: x.signum
|
||||
is_const: false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ pub fn fraction(n i64, d i64) Fraction {
|
|||
return fraction(-n, -d)
|
||||
}
|
||||
return Fraction{
|
||||
n: n
|
||||
d: d
|
||||
n: n
|
||||
d: d
|
||||
is_reduced: math.gcd(n, d) == 1
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ fn general_addition_result(f1 Fraction, f2 Fraction, addition bool) Fraction {
|
|||
num1d2n := f1.d * f2.n
|
||||
n := if addition { num1n2d + num1d2n } else { num1n2d - num1d2n }
|
||||
return Fraction{
|
||||
n: n
|
||||
d: f1.d * f2.d
|
||||
n: n
|
||||
d: f1.d * f2.d
|
||||
is_reduced: true
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ fn general_addition_result(f1 Fraction, f2 Fraction, addition bool) Fraction {
|
|||
t := if addition { term1 + term2 } else { term1 - term2 }
|
||||
d2 := math.gcd(t, d1)
|
||||
return Fraction{
|
||||
n: t / d2
|
||||
d: f1den * (f2.d / d2)
|
||||
n: t / d2
|
||||
d: f1den * (f2.d / d2)
|
||||
is_reduced: true
|
||||
}
|
||||
}
|
||||
|
@ -106,16 +106,16 @@ fn general_multiplication_result(f1 Fraction, f2 Fraction, multiplication bool)
|
|||
d1 := math.gcd(f1.n, f2.d)
|
||||
d2 := math.gcd(f1.d, f2.n)
|
||||
return Fraction{
|
||||
n: (f1.n / d1) * (f2.n / d2)
|
||||
d: (f2.d / d1) * (f1.d / d2)
|
||||
n: (f1.n / d1) * (f2.n / d2)
|
||||
d: (f2.d / d1) * (f1.d / d2)
|
||||
is_reduced: true
|
||||
}
|
||||
} else {
|
||||
d1 := math.gcd(f1.n, f2.n)
|
||||
d2 := math.gcd(f1.d, f2.d)
|
||||
return Fraction{
|
||||
n: (f1.n / d1) * (f2.d / d2)
|
||||
d: (f2.n / d1) * (f1.d / d2)
|
||||
n: (f1.n / d1) * (f2.d / d2)
|
||||
d: (f2.n / d1) * (f1.d / d2)
|
||||
is_reduced: true
|
||||
}
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ pub fn (f1 Fraction) / (f2 Fraction) Fraction {
|
|||
// Fraction negate method
|
||||
pub fn (f Fraction) negate() Fraction {
|
||||
return Fraction{
|
||||
n: -f.n
|
||||
d: f.d
|
||||
n: -f.n
|
||||
d: f.d
|
||||
is_reduced: f.is_reduced
|
||||
}
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ pub fn (f Fraction) reciprocal() Fraction {
|
|||
panic('Denominator cannot be zero')
|
||||
}
|
||||
return Fraction{
|
||||
n: f.d
|
||||
d: f.n
|
||||
n: f.d
|
||||
d: f.n
|
||||
is_reduced: f.is_reduced
|
||||
}
|
||||
}
|
||||
|
@ -167,8 +167,8 @@ pub fn (f Fraction) reduce() Fraction {
|
|||
}
|
||||
cf := math.gcd(f.n, f.d)
|
||||
return Fraction{
|
||||
n: f.n / cf
|
||||
d: f.d / cf
|
||||
n: f.n / cf
|
||||
d: f.d / cf
|
||||
is_reduced: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ pub mut:
|
|||
pub fn divide_truncated[T](numer T, denom T) DivResult[T] {
|
||||
return DivResult[T]{
|
||||
quot: numer / denom
|
||||
rem: numer % denom
|
||||
rem: numer % denom
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ pub fn divide_euclid[T](numer T, denom T) DivResult[T] {
|
|||
}
|
||||
return DivResult[T]{
|
||||
quot: q
|
||||
rem: r
|
||||
rem: r
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ pub fn divide_floored[T](numer T, denom T) DivResult[T] {
|
|||
}
|
||||
return DivResult[T]{
|
||||
quot: q
|
||||
rem: r
|
||||
rem: r
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@ const sin_data = [
|
|||
-1.1821555255364833468288e-19,
|
||||
]
|
||||
const sin_cs = ChebSeries{
|
||||
c: sin_data
|
||||
c: sin_data
|
||||
order: 11
|
||||
a: -1
|
||||
b: 1
|
||||
a: -1
|
||||
b: 1
|
||||
}
|
||||
const cos_data = [
|
||||
0.165391825637921473505668118136,
|
||||
|
@ -36,10 +36,10 @@ const cos_data = [
|
|||
-3.7363121133079412079201377318e-18,
|
||||
]
|
||||
const cos_cs = ChebSeries{
|
||||
c: cos_data
|
||||
c: cos_data
|
||||
order: 10
|
||||
a: -1
|
||||
b: 1
|
||||
a: -1
|
||||
b: 1
|
||||
}
|
||||
|
||||
// sin calculates the sine of the angle in radians
|
||||
|
|
|
@ -41,53 +41,53 @@ fn new(x u64, y u64) unsigned.Uint128 {
|
|||
fn test_leading_zeros() {
|
||||
tcs := [
|
||||
LeadingZeros{
|
||||
l: new(0x00, 0xf000000000000000)
|
||||
r: new(0x00, 0x8000000000000000)
|
||||
l: new(0x00, 0xf000000000000000)
|
||||
r: new(0x00, 0x8000000000000000)
|
||||
zeros: 1
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0x00, 0xf000000000000000)
|
||||
r: new(0x00, 0xc000000000000000)
|
||||
l: new(0x00, 0xf000000000000000)
|
||||
r: new(0x00, 0xc000000000000000)
|
||||
zeros: 2
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0x00, 0xf000000000000000)
|
||||
r: new(0x00, 0xe000000000000000)
|
||||
l: new(0x00, 0xf000000000000000)
|
||||
r: new(0x00, 0xe000000000000000)
|
||||
zeros: 3
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0x00, 0xffff000000000000)
|
||||
r: new(0x00, 0xff00000000000000)
|
||||
l: new(0x00, 0xffff000000000000)
|
||||
r: new(0x00, 0xff00000000000000)
|
||||
zeros: 8
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0x00, 0x000000000000ffff)
|
||||
r: new(0x00, 0x000000000000ff00)
|
||||
l: new(0x00, 0x000000000000ffff)
|
||||
r: new(0x00, 0x000000000000ff00)
|
||||
zeros: 56
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0xf000000000000000, 0x01)
|
||||
r: new(0x4000000000000000, 0x00)
|
||||
l: new(0xf000000000000000, 0x01)
|
||||
r: new(0x4000000000000000, 0x00)
|
||||
zeros: 63
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0xf000000000000000, 0x00)
|
||||
r: new(0x4000000000000000, 0x00)
|
||||
l: new(0xf000000000000000, 0x00)
|
||||
r: new(0x4000000000000000, 0x00)
|
||||
zeros: 64
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0xf000000000000000, 0x00)
|
||||
r: new(0x8000000000000000, 0x00)
|
||||
l: new(0xf000000000000000, 0x00)
|
||||
r: new(0x8000000000000000, 0x00)
|
||||
zeros: 65
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0x00, 0x00)
|
||||
r: new(0x00, 0x00)
|
||||
l: new(0x00, 0x00)
|
||||
r: new(0x00, 0x00)
|
||||
zeros: 128
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(0x01, 0x00)
|
||||
r: new(0x00, 0x00)
|
||||
l: new(0x01, 0x00)
|
||||
r: new(0x00, 0x00)
|
||||
zeros: 127
|
||||
},
|
||||
]
|
||||
|
|
|
@ -138,53 +138,53 @@ fn new(x unsigned.Uint128, y unsigned.Uint128) unsigned.Uint256 {
|
|||
fn test_leading_zeros() {
|
||||
tcs := [
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xf000000000000000))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x8000000000000000))
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xf000000000000000))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x8000000000000000))
|
||||
zeros: 65
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xf000000000000000))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xc000000000000000))
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xf000000000000000))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xc000000000000000))
|
||||
zeros: 66
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xf000000000000000))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xe000000000000000))
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xf000000000000000))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xe000000000000000))
|
||||
zeros: 67
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xffff000000000000))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xff00000000000000))
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xffff000000000000))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0xff00000000000000))
|
||||
zeros: 72
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x000000000000ffff))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x000000000000ff00))
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x000000000000ffff))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x000000000000ff00))
|
||||
zeros: 120
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0xf000000000000000), unsigned.uint128_from_64(0x01))
|
||||
r: new(unsigned.uint128_from_64(0x4000000000000000), unsigned.uint128_from_64(0x00))
|
||||
l: new(unsigned.uint128_from_64(0xf000000000000000), unsigned.uint128_from_64(0x01))
|
||||
r: new(unsigned.uint128_from_64(0x4000000000000000), unsigned.uint128_from_64(0x00))
|
||||
zeros: 127
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0xf000000000000000), unsigned.uint128_from_64(0x00))
|
||||
r: new(unsigned.uint128_from_64(0x4000000000000000), unsigned.uint128_from_64(0x00))
|
||||
l: new(unsigned.uint128_from_64(0xf000000000000000), unsigned.uint128_from_64(0x00))
|
||||
r: new(unsigned.uint128_from_64(0x4000000000000000), unsigned.uint128_from_64(0x00))
|
||||
zeros: 192
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0xf000000000000000), unsigned.uint128_from_64(0x00))
|
||||
r: new(unsigned.uint128_from_64(0x8000000000000000), unsigned.uint128_from_64(0x00))
|
||||
l: new(unsigned.uint128_from_64(0xf000000000000000), unsigned.uint128_from_64(0x00))
|
||||
r: new(unsigned.uint128_from_64(0x8000000000000000), unsigned.uint128_from_64(0x00))
|
||||
zeros: 193
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x00))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x00))
|
||||
l: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x00))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x00))
|
||||
zeros: 256
|
||||
},
|
||||
LeadingZeros{
|
||||
l: new(unsigned.uint128_from_64(0x01), unsigned.uint128_from_64(0x00))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x00))
|
||||
l: new(unsigned.uint128_from_64(0x01), unsigned.uint128_from_64(0x00))
|
||||
r: new(unsigned.uint128_from_64(0x00), unsigned.uint128_from_64(0x00))
|
||||
zeros: 255
|
||||
},
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue