From d0ab555029eebd5942d82700cfceddbfcc3a9dae Mon Sep 17 00:00:00 2001 From: mertcandav Date: Fri, 27 Sep 2024 17:06:02 +0300 Subject: [PATCH] maintain: refactor all jule codebase with julefmt --- src/julec/handle/logger.jule | 2 +- src/julec/main.jule | 2 +- src/julec/obj/cxx/expr.jule | 8 +-- src/julec/obj/cxx/object.jule | 6 +-- src/julec/opt/deadcode/scope.jule | 4 +- std/bytes/bytes.jule | 8 +-- std/conv/atof.jule | 30 +++++------ std/conv/atoi.jule | 8 +-- std/conv/decimal.jule | 12 ++--- std/conv/eisel_lemire.jule | 8 +-- std/conv/ftoa.jule | 54 +++++++++---------- std/conv/ftoaryu.jule | 28 +++++----- std/conv/itoa.jule | 6 +-- std/encoding/ascii85/ascii85.jule | 12 ++--- std/encoding/ascii85/ascii85_test.jule | 4 +- std/encoding/base32/base32.jule | 4 +- std/encoding/base64/base64.jule | 6 +-- std/encoding/binary/big_endian.jule | 30 +++++------ std/encoding/binary/little_endian.jule | 30 +++++------ std/encoding/json/buffer.jule | 2 +- std/encoding/json/decode.jule | 10 ++-- std/encoding/json/encode.jule | 8 +-- std/fs/file.jule | 4 +- std/hash/adler32/adler32.jule | 4 +- std/hash/fnv/fnv.jule | 4 +- std/internal/byteorder/byteorder.jule | 60 ++++++++++----------- std/internal/conv/atoi.jule | 4 +- std/internal/conv/itoa.jule | 2 +- std/jule/constant/lit/bytes.jule | 2 +- std/jule/integrated/conv.jule | 4 +- std/jule/parser/parser.jule | 2 +- std/jule/sema/builtin.jule | 4 +- std/jule/sema/eval.jule | 4 +- std/jule/sema/scope.jule | 2 +- std/jule/sema/sema.jule | 2 +- std/jule/types/bits.jule | 10 ++-- std/math/acosh.jule | 4 +- std/math/asin.jule | 6 +-- std/math/asinh.jule | 4 +- std/math/atan.jule | 8 +-- std/math/atan2.jule | 8 +-- std/math/atanh.jule | 4 +- std/math/big/bits.jule | 10 ++-- std/math/big/conv.jule | 22 ++++---- std/math/big/nat.jule | 20 +++---- std/math/bits.jule | 2 +- std/math/bits/bits.jule | 68 ++++++++++++------------ std/math/cbrt.jule | 12 ++--- std/math/cmplx/asin.jule | 30 +++++------ std/math/cmplx/cmplx.jule | 10 ++-- std/math/cmplx/exp.jule | 2 +- std/math/cmplx/log.jule | 2 +- std/math/cmplx/pow.jule | 2 +- std/math/cmplx/rect.jule | 2 +- std/math/cmplx/sin.jule | 16 +++--- std/math/cmplx/sqrt.jule | 8 +-- std/math/cmplx/tan.jule | 24 ++++----- std/math/copysign.jule | 2 +- std/math/erf.jule | 60 ++++++++++----------- std/math/erfinv.jule | 16 +++--- std/math/exp.jule | 10 ++-- std/math/expm1.jule | 28 +++++----- std/math/floor.jule | 8 +-- std/math/fma.jule | 26 +++++----- std/math/frexp.jule | 2 +- std/math/gamma.jule | 14 ++--- std/math/hypot.jule | 2 +- std/math/j0.jule | 34 ++++++------ std/math/j1.jule | 28 +++++----- std/math/jn.jule | 18 +++---- std/math/ldexp.jule | 4 +- std/math/lgamma.jule | 42 +++++++-------- std/math/log.jule | 6 +-- std/math/log10.jule | 2 +- std/math/log1p.jule | 14 ++--- std/math/logb.jule | 2 +- std/math/mod.jule | 2 +- std/math/pow.jule | 2 +- std/math/rand/rand.jule | 12 ++--- std/math/remainder.jule | 2 +- std/math/signbit.jule | 2 +- std/math/sin.jule | 12 ++--- std/math/sincos.jule | 6 +-- std/math/sinh.jule | 8 +-- std/math/sqrt.jule | 4 +- std/math/tan.jule | 4 +- std/math/tanh.jule | 4 +- std/math/trig_reduce.jule | 6 +-- std/net/ip.jule | 6 +-- std/net/ip_addr.jule | 20 +++---- std/net/mac.jule | 6 +-- std/net/sock_unix.jule | 2 +- std/net/sock_windows.jule | 2 +- std/net/tcp.jule | 2 +- std/net/udp.jule | 2 +- std/process/cmd_unix.jule | 4 +- std/process/cmd_windows.jule | 2 +- std/runtime/conv.jule | 2 +- std/runtime/env_darwin.jule | 1 - std/runtime/env_linux.jule | 1 - std/runtime/env_unix.jule | 4 +- std/runtime/env_windows.jule | 3 +- std/runtime/map.jule | 2 +- std/runtime/maphash.jule | 72 +++++++++++++------------- std/runtime/rand.jule | 8 +-- std/runtime/strings.jule | 2 +- std/runtime/thread_unix.jule | 1 - std/slices/sortfunc.jule | 16 +++--- std/slices/sortordered.jule | 16 +++--- std/strings/strings.jule | 6 +-- std/sys/net.jule | 4 +- std/sys/net_windows.jule | 2 +- std/sys/syscall_unix.jule | 2 +- std/time/duration.jule | 16 +++--- std/time/time.jule | 18 +++---- std/unicode/letter.jule | 8 +-- std/unicode/utf16/utf16.jule | 4 +- std/unicode/utf8/utf8.jule | 58 ++++++++++----------- 118 files changed, 664 insertions(+), 664 deletions(-) diff --git a/src/julec/handle/logger.jule b/src/julec/handle/logger.jule index fa43026fe..b0360f005 100644 --- a/src/julec/handle/logger.jule +++ b/src/julec/handle/logger.jule @@ -47,7 +47,7 @@ impl Logger { out("\n ") out(strings::Repeat(" ", len(row))) out(" | ") - out(strings::Repeat(" ", l.Column - offset)) + out(strings::Repeat(" ", l.Column-offset)) out("^") if len(l.Suggestion) != 0 { out("\n ") diff --git a/src/julec/main.jule b/src/julec/main.jule index 29ae604a4..8dad0d75d 100644 --- a/src/julec/main.jule +++ b/src/julec/main.jule @@ -50,7 +50,7 @@ fn help(&args: []str) { const Space = 5 // Space of between command name and description. for i, part in HelpMap { s.WriteStr(part[0]) - s.WriteStr(strings::Repeat(" ", (max - len(part[0])) + Space)) + s.WriteStr(strings::Repeat(" ", (max-len(part[0]))+Space)) s.WriteStr(part[1]) if i+1 < len(HelpMap) { s.WriteByte('\n') diff --git a/src/julec/obj/cxx/expr.jule b/src/julec/obj/cxx/expr.jule index 293cbe7b0..f532370e1 100644 --- a/src/julec/obj/cxx/expr.jule +++ b/src/julec/obj/cxx/expr.jule @@ -170,7 +170,7 @@ impl exprCoder { | x == MinF32: self.oc.write("jule::MIN_F32") |: - ftoa(self.oc.Buf, x, 1 << 5) + ftoa(self.oc.Buf, x, 1<<5) self.oc.write("f") } } @@ -189,7 +189,7 @@ impl exprCoder { | x == MinF64: self.oc.write("jule::MIN_F64") |: - ftoa(self.oc.Buf, x, 1 << 6) + ftoa(self.oc.Buf, x, 1<<6) } } @@ -1224,7 +1224,7 @@ impl exprCoder { self.oc.write(mapVar) self.oc.write(" = ") identCoder.funcIns(self.oc.Buf, maker) - self.oc.write("(); ") + self.oc.write("(); ") for (_, mut pair) in m.Entries { self.oc.write("(*") identCoder.funcIns(self.oc.Buf, f) @@ -2094,7 +2094,7 @@ fn operatorOverloadingBinary(mut &buf: StrBuilder, mut &s: &StructIns, &l: str, // Equal method not exist. Compiler will create, use default method. identCoder.structureIns(buf, s) buf.WriteStr(structDefaultEqMethodSuffix) - goto common + goto common } panic("binary operator overloading is not exist, this is an implementation mistake") } diff --git a/src/julec/obj/cxx/object.jule b/src/julec/obj/cxx/object.jule index 9e3ad93c6..7c2350604 100644 --- a/src/julec/obj/cxx/object.jule +++ b/src/julec/obj/cxx/object.jule @@ -1315,8 +1315,8 @@ impl ObjectCoder { fn end(mut &self) { self.write(`int main(int argc, char *argv[], char *envp[]) {`) self.write("\n\n") - self.initGlobals() - self.write(` + self.initGlobals() + self.write(` __jule_argc = static_cast(argc); __jule_argv = reinterpret_cast(argv); __jule_envp = reinterpret_cast(envp); @@ -1338,7 +1338,7 @@ impl ObjectCoder { fn insertBuf(mut &self, mut &buf: StrBuilder, pos: int) { if buf.Len() > 0 { - mut head := make([]byte, 0, self.Buf.Len() + buf.Len()) + mut head := make([]byte, 0, self.Buf.Len()+buf.Len()) head = append(head, unsafe { self.Buf.Buf() }[:pos]...) head = append(head, unsafe { buf.Buf() }...) head = append(head, unsafe { self.Buf.Buf() }[pos:]...) diff --git a/src/julec/opt/deadcode/scope.jule b/src/julec/opt/deadcode/scope.jule index 6000bd416..195a4b5e8 100644 --- a/src/julec/opt/deadcode/scope.jule +++ b/src/julec/opt/deadcode/scope.jule @@ -236,8 +236,8 @@ impl scopeDeadCode { } fn eliminateDeadCodeOfScope(mut s: &Scope) { - labels := make([]&Label, 0, 1 << 4) - gotos := make([]&GotoSt, 0, 1 << 4) + labels := make([]&Label, 0, 1<<4) + gotos := make([]&GotoSt, 0, 1<<4) mut sdc := &scopeDeadCode{ s: s, labels: unsafe { (&[]&Label)(&labels) }, diff --git a/std/bytes/bytes.jule b/std/bytes/bytes.jule index f958a33b0..d1290f2ca 100644 --- a/std/bytes/bytes.jule +++ b/std/bytes/bytes.jule @@ -21,7 +21,7 @@ fn Repeat(s: []byte, mut n: int): []byte { panic("std::bytes: repeat: integer buffer size overflow") } - mut buff := make([]byte, len(s) * n) + mut buff := make([]byte, len(s)*n) mut i := 0 for n > 0; n-- { i += copy(buff[i:], s) @@ -116,7 +116,7 @@ loop: // returns -1 if not exist any match. Starts searching at right // of slice to left. fn FindLast(s: []byte, sub: []byte): int { - ret FindLastAt(s, sub, len(s) - 1) + ret FindLastAt(s, sub, len(s)-1) } // Returns index of first matched item with specified byte, @@ -210,7 +210,7 @@ fn FindFnLastAt(s: []byte, mut i: int, f: fn(mut rune): bool): int { // returns -1 if not exist any match. Starts searching at right // of slice to left. fn FindFnLast(s: []byte, f: fn(mut rune): bool): int { - ret FindFnLastAt(s, len(s) - 1, f) + ret FindFnLastAt(s, len(s)-1, f) } // Returns index of first matched item with any of runes, @@ -336,7 +336,7 @@ fn Replace(mut s: []byte, sub: []byte, new: []byte, mut n: int): []byte { n = m } - mut ss := make([]byte, 0, len(s) + n * (len(new) - len(sub))) + mut ss := make([]byte, 0, len(s)+n*(len(new)-len(sub))) mut i := 0 for n > 0; n-- { j := FindAt(s, sub, i) diff --git a/std/conv/atof.jule b/std/conv/atof.jule index e4d6e5d74..b8529af48 100644 --- a/std/conv/atof.jule +++ b/std/conv/atof.jule @@ -214,7 +214,7 @@ loop_end: continue } if e < 10000 { - e = e * 10 + int(s[i]) - '0' + e = e*10 + int(s[i]) - '0' } } dp += e * esign @@ -315,7 +315,7 @@ impl decimal { continue } if e < 10000 { - e = e * 10 + int(s[i]) - '0' + e = e*10 + int(s[i]) - '0' } } self.dp += e * esign @@ -406,7 +406,7 @@ impl decimal { } // Denormalized? - if mant&(1 << flt.mantbits) == 0 { + if mant&(1<>(1 + flt.mantbits + 2) != 0 { - mantissa = mantissa >> 1 | mantissa & 1 + for mantissa>>(1+flt.mantbits+2) != 0 { + mantissa = mantissa>>1 | mantissa&1 exp++ } @@ -580,7 +580,7 @@ fn atofHex(&flt: floatInfo, mut mantissa: u64, mut exp: int, neg: bool, trunc: b // denormalize in hopes of making it representable. // (The -2 is for the rounding bits.) for mantissa > 1 && exp < minExp-2 { - mantissa = mantissa >> 1 | mantissa & 1 + mantissa = mantissa>>1 | mantissa&1 exp++ } @@ -591,7 +591,7 @@ fn atofHex(&flt: floatInfo, mut mantissa: u64, mut exp: int, neg: bool, trunc: b exp += 2 if round == 3 { mantissa++ - if mantissa == 1<<(1 + flt.mantbits) { + if mantissa == 1<<(1+flt.mantbits) { mantissa >>= 1 exp++ } @@ -607,8 +607,8 @@ fn atofHex(&flt: floatInfo, mut mantissa: u64, mut exp: int, neg: bool, trunc: b err = ConvError.OutOfRange } - mut bits := mantissa & (1 << flt.mantbits - 1) - bits |= u64((exp - flt.bias) & int(1 << flt.expbits - 1)) << flt.mantbits + mut bits := mantissa & (1<= cutoff { error(ConvError.OutOfRange) } diff --git a/std/conv/decimal.jule b/std/conv/decimal.jule index 7de441881..96f21be57 100644 --- a/std/conv/decimal.jule +++ b/std/conv/decimal.jule @@ -249,7 +249,7 @@ impl decimal { mut i := 0 mut n := u64(0) for i < self.dp && i < self.nd; i++ { - n = n * 10 + u64(self.d[i] - '0') + n = n*10 + u64(self.d[i]-'0') } for i < self.dp; i++ { n *= 10 @@ -301,11 +301,11 @@ fn rightShift(mut &a: decimal, k: uint) { break } c := uint(a.d[r]) - n = n * 10 + c - '0' + n = n*10 + c - '0' } a.dp -= r - 1 - mask := uint(1 << k) - 1 + mask := uint(1<= 0; r-- { n += (uint(a.d[r]) - '0') << k quo := n / 10 - rem := n - 10 * quo + rem := n - 10*quo w-- if w < len(a.d) { a.d[w] = byte(rem + '0') @@ -377,7 +377,7 @@ fn leftShift(mut &a: decimal, k: uint) { // Put down extra digits. for n > 0 { quo := n / 10 - rem := n - 10 * quo + rem := n - 10*quo w-- if w < len(a.d) { a.d[w] = byte(rem + '0') diff --git a/std/conv/eisel_lemire.jule b/std/conv/eisel_lemire.jule index c28a17ba0..f30e10d0c 100644 --- a/std/conv/eisel_lemire.jule +++ b/std/conv/eisel_lemire.jule @@ -57,7 +57,7 @@ fn eiselLemire64(mut man: u64, exp10: int, neg: bool): (f: f64, ok: bool) { clz := bits::LeadingZeros64(man) man <<= uint(clz) const f64ExponentBias = 1023 - mut retExp2 := u64(217706 * exp10 >> 16 + 64 + f64ExponentBias) - u64(clz) + mut retExp2 := u64(217706*exp10>>16+64+f64ExponentBias) - u64(clz) // Multiplication. mut xHi, mut xLo := bits::Mul64(man, detailedPowsOfTen[exp10-detailedPowsOfTenMinExp10][1]) @@ -100,7 +100,7 @@ fn eiselLemire64(mut man: u64, exp10: int, neg: bool): (f: f64, ok: bool) { if retExp2-1 >= 0x7FF-1 { ret 0, false } - mut retBits := retExp2 << 52 | retMantissa & 0x000FFFFFFFFFFFFF + mut retBits := retExp2<<52 | retMantissa&0x000FFFFFFFFFFFFF if neg { retBits |= 0x8000000000000000 } @@ -132,7 +132,7 @@ fn eiselLemire32(mut man: u64, exp10: int, neg: bool): (f: f32, ok: bool) { clz := bits::LeadingZeros64(man) man <<= uint(clz) const f32ExponentBias = 127 - mut retExp2 := u64(217706 * exp10 >> 16 + 64 + f32ExponentBias) - u64(clz) + mut retExp2 := u64(217706*exp10>>16+64+f32ExponentBias) - u64(clz) // Multiplication. mut x_hi, mut x_lo := bits::Mul64(man, detailedPowsOfTen[exp10-detailedPowsOfTenMinExp10][1]) @@ -175,7 +175,7 @@ fn eiselLemire32(mut man: u64, exp10: int, neg: bool): (f: f32, ok: bool) { if retExp2-1 >= 0xFF-1 { ret 0, false } - mut retBits := retExp2 << 23 | retMantissa & 0x007FFFFF + mut retBits := retExp2<<23 | retMantissa&0x007FFFFF if neg { retBits |= 0x80000000 } diff --git a/std/conv/ftoa.jule b/std/conv/ftoa.jule index f1e3c2d71..42f659dea 100644 --- a/std/conv/ftoa.jule +++ b/std/conv/ftoa.jule @@ -81,7 +81,7 @@ fn FmtFloat(f: f64, fmt: byte, prec: int, bitSize: int): str { // It returns always head pointer of slice, so deallocation is safe. // There is no need to make new allocation for string. ret unsafe::StrFromBytes( - genericFtoa(make([]byte, 0, max(prec + 4 + 1, 24 + 1)), f, fmt, prec, bitSize)) + genericFtoa(make([]byte, 0, max(prec+4+1, 24+1)), f, fmt, prec, bitSize)) } fn genericFtoa(mut dst: []byte, val: f64, fmt: byte, mut prec: int, bitSize: int): []byte { @@ -98,12 +98,12 @@ fn genericFtoa(mut dst: []byte, val: f64, fmt: byte, mut prec: int, bitSize: int panic("std::conv: illegal bitSize") } - neg := bits>>(flt.expbits + flt.mantbits) != 0 - mut exp := int(bits >> flt.mantbits) & int(1 << flt.expbits - 1) - mut mant := bits & (u64(1) << flt.mantbits - 1) + neg := bits>>(flt.expbits+flt.mantbits) != 0 + mut exp := int(bits>>flt.mantbits) & int(1< digs.nd { prec = digs.nd } - ret fmtE(dst, neg, digs, prec - 1, fmt + 'e' - 'g') + ret fmtE(dst, neg, digs, prec-1, fmt+'e'-'g') } if prec > digs.dp { prec = digs.nd } - ret fmtF(dst, neg, digs, max(prec - digs.dp, 0)) + ret fmtF(dst, neg, digs, max(prec-digs.dp, 0)) } // unknown format @@ -290,7 +290,7 @@ fn roundShortest(mut &d: decimal, mant: u64, exp: int, &flt: floatInfo) { // Next highest floating point number is mant+1 << exp-mantbits. // Our upper bound is halfway between, mant*2+1 << exp-mantbits-1. mut upper := decimal{} - upper.assign(mant * 2 + 1) + upper.assign(mant*2 + 1) upper.shift(exp - int(flt.mantbits) - 1) // d = mant << (exp - mantbits) @@ -305,11 +305,11 @@ fn roundShortest(mut &d: decimal, mant: u64, exp: int, &flt: floatInfo) { mantlo = mant - 1 explo = exp } else { - mantlo = mant * 2 - 1 + mantlo = mant*2 - 1 explo = exp - 1 } mut lower := decimal{} - lower.assign(mantlo * 2 + 1) + lower.assign(mantlo*2 + 1) lower.shift(explo - int(flt.mantbits) - 1) // The upper and lower bounds are possible outputs only if @@ -415,7 +415,7 @@ fn fmtE(mut dst: []byte, neg: bool, d: decimalSlice, prec: int, fmt: byte): []by if prec > 0 { dst = append(dst, '.') mut i := 1 - m := min(d.nd, prec + 1) + m := min(d.nd, prec+1) if i < m { dst = append(dst, d.d[i:m]...) i = m @@ -442,11 +442,11 @@ fn fmtE(mut dst: []byte, neg: bool, d: decimalSlice, prec: int, fmt: byte): []by // dd or ddd match { | exp < 10: - dst = append(dst, '0', byte(exp) + '0') + dst = append(dst, '0', byte(exp)+'0') | exp < 100: - dst = append(dst, byte(exp / 10) + '0', byte(exp % 10) + '0') + dst = append(dst, byte(exp/10)+'0', byte(exp%10)+'0') |: - dst = append(dst, byte(exp / 100) + '0', byte(exp / 10) % 10 + '0', byte(exp % 10) + '0') + dst = append(dst, byte(exp/100)+'0', byte(exp/10)%10+'0', byte(exp%10)+'0') } ret dst @@ -524,13 +524,13 @@ fn fmtX(mut dst: []byte, prec: int, fmt: byte, neg: bool, // Round if requested. if prec >= 0 && prec < 15 { shift := uint(prec * 4) - extra := (mant << shift) & (1 << 60 - 1) + extra := (mant << shift) & (1<<60 - 1) mant >>= 60 - shift - if extra|(mant & 1) > 1<<59 { + if extra|(mant&1) > 1<<59 { mant++ } mant <<= 60 - shift - if mant&(1 << 61) != 0 { + if mant&(1<<61) != 0 { // Wrapped around. mant >>= 1 exp++ @@ -548,7 +548,7 @@ fn fmtX(mut dst: []byte, prec: int, fmt: byte, neg: bool, if neg { dst = append(dst, '-') } - dst = append(dst, '0', fmt, '0' + byte((mant >> 60) & 1)) + dst = append(dst, '0', fmt, '0'+byte((mant>>60)&1)) // .fraction mant <<= 4 // remove leading 0 or 1 @@ -584,11 +584,11 @@ fn fmtX(mut dst: []byte, prec: int, fmt: byte, neg: bool, // dd or ddd or dddd match { | exp < 100: - dst = append(dst, byte(exp / 10) + '0', byte(exp % 10) + '0') + dst = append(dst, byte(exp/10)+'0', byte(exp%10)+'0') | exp < 1000: - dst = append(dst, byte(exp / 100) + '0', byte((exp / 10) % 10) + '0', byte(exp % 10) + '0') + dst = append(dst, byte(exp/100)+'0', byte((exp/10)%10)+'0', byte(exp%10)+'0') |: - dst = append(dst, byte(exp / 1000) + '0', byte(exp / 100) % 10 + '0', byte((exp / 10) % 10) + '0', byte(exp % 10) + '0') + dst = append(dst, byte(exp/1000)+'0', byte(exp/100)%10+'0', byte((exp/10)%10)+'0', byte(exp%10)+'0') } ret dst } diff --git a/std/conv/ftoaryu.jule b/std/conv/ftoaryu.jule index 7089eba92..4235c4671 100644 --- a/std/conv/ftoaryu.jule +++ b/std/conv/ftoaryu.jule @@ -92,7 +92,7 @@ fn ryuFtoaFixed32(mut &d: decimalSlice, mut mant: u32, exp: int, prec: int) { } // Remove extra lower bits and keep rounding info. extra := uint(-dexp2) - extraMask := u32(1 << extra - 1) + extraMask := u32(1<> extra, di & extraMask @@ -106,7 +106,7 @@ fn ryuFtoaFixed32(mut &d: decimalSlice, mut mant: u32, exp: int, prec: int) { } else { // otherwise, d+1/2 always rounds up because // we truncated below. - roundUp = dfrac>>(extra - 1) == 1 + roundUp = dfrac>>(extra-1) == 1 } if dfrac != 0 { d0 = false @@ -131,7 +131,7 @@ fn ryuFtoaFixed64(mut &d: decimalSlice, mut mant: u64, exp: int, prec: int) { mut e2 := exp b := bits::Len64(mant) if b < 55 { - mant = mant << uint(55 - b) + mant = mant << uint(55-b) e2 += int(b) - 55 } // Choose an exponent such that rounded mant*(2^e2)*(10^q) has @@ -164,7 +164,7 @@ fn ryuFtoaFixed64(mut &d: decimalSlice, mut mant: u64, exp: int, prec: int) { } // Remove extra lower bits and keep rounding info. extra := uint(-dexp2) - extraMask := u64(1 << extra - 1) + extraMask := u64(1<> extra, di & extraMask @@ -178,7 +178,7 @@ fn ryuFtoaFixed64(mut &d: decimalSlice, mut mant: u64, exp: int, prec: int) { } else { // otherwise, d+1/2 always rounds up because // we truncated below. - roundUp = dfrac>>(extra - 1) == 1 + roundUp = dfrac>>(extra-1) == 1 } if dfrac != 0 { d0 = false @@ -323,7 +323,7 @@ fn ryuFtoaShortest(mut &d: decimalSlice, mut mant: u64, exp: int, &flt: floatInf // Express the results (dl, dc, du)*2^e2 as integers. // Extra bits must be removed and rounding hints computed. extra := uint(-e2) - extraMask := u64(1 << extra - 1) + extraMask := u64(1<> extra, dl & extraMask @@ -353,7 +353,7 @@ fn ryuFtoaShortest(mut &d: decimalSlice, mut mant: u64, exp: int, &flt: floatInf } else { // otherwise, the result is a lower truncation of the ideal // result. - cup = fracc>>(extra - 1) == 1 + cup = fracc>>(extra-1) == 1 } // Is 'dl' an allowed representation? // Only if it is an exact value, and if the original binary mantissa @@ -396,11 +396,11 @@ fn computeBounds(mant: u64, exp: int, &flt: floatInfo): (lower: u64, central: u64, upper: u64, e2: int) { if mant != 1< 0 && d.d[d.nd-1] == '0' { @@ -547,7 +547,7 @@ fn mult64bitPow10(m: u32, mut e2: int, q: int): (resM: u32, resE: int, exact: bo } hi, lo := bits::Mul64(u64(m), pow) e2 += mulByLog10Log2(q) - 63 + 57 - ret u32(hi << 7 | lo >> 57), e2, lo<<7 == 0 + ret u32(hi<<7 | lo>>57), e2, lo<<7 == 0 } // Takes a floating-point input with a 55-bit @@ -580,7 +580,7 @@ fn mult128bitPow10(m: u64, mut e2: int, q: int): (resM: u64, resE: int, exact: b mut h1, h0 := bits::Mul64(m, pow[1]) mid, carry := bits::Add64(l1, h0, 0) h1 += carry - ret h1 << 9 | mid >> 55, e2, mid<<9 == 0 && l0 == 0 + ret h1<<9 | mid>>55, e2, mid<<9 == 0 && l0 == 0 } fn divisibleByPow5(mut m: u64, k: int): bool { @@ -604,7 +604,7 @@ fn divmod1e9(x: u64): (u32, u32) { ret u32(x / 1e9), u32(x % 1e9) } // Use the same sequence of operations as the amd64 compiler. - hi, _ := bits::Mul64(x >> 1, 0x89705f4136b4a598) // binary digits of 1e-9 + hi, _ := bits::Mul64(x>>1, 0x89705f4136b4a598) // binary digits of 1e-9 q := hi >> 28 - ret u32(q), u32(x - q * 1e9) + ret u32(q), u32(x - q*1e9) } \ No newline at end of file diff --git a/std/conv/itoa.jule b/std/conv/itoa.jule index 64a080637..60c987af2 100644 --- a/std/conv/itoa.jule +++ b/std/conv/itoa.jule @@ -94,7 +94,7 @@ fn small(i: int): str { } fn isPowerOfTwo(x: int): bool { - ret x&(x - 1) == 0 + ret x&(x-1) == 0 } // Computes the string representation of u in the given base. @@ -108,7 +108,7 @@ fn fmtBits(mut dst: []byte, mut u: u64, base: int, neg: bool, append_: bool): (d } // 2 <= base && base <= len(digits) - mut a := make([]byte, 64 + 1) // +1 for sign of 64bit value in base 2 + mut a := make([]byte, 64+1) // +1 for sign of 64bit value in base 2 mut i := len(a) if neg { @@ -130,7 +130,7 @@ fn fmtBits(mut dst: []byte, mut u: u64, base: int, neg: bool, append_: bool): (d // since 64bit division and modulo operations // are calculated by runtime functions on 32bit machines. q := u / 1e9 - mut us := uint(u - q * 1e9) // u % 1e9 fits into a uint + mut us := uint(u - q*1e9) // u % 1e9 fits into a uint mut j := 4 for j > 0; j-- { is := us % 100 * 2 diff --git a/std/encoding/ascii85/ascii85.jule b/std/encoding/ascii85/ascii85.jule index bd27d3b6b..8003dc8ca 100644 --- a/std/encoding/ascii85/ascii85.jule +++ b/std/encoding/ascii85/ascii85.jule @@ -106,7 +106,7 @@ fn Encode(mut dest: []byte, src: []byte): int { // Otherwise, 5 base 85 digits starting at !. mut i := 4 for i >= 0; i-- { - dest[i] = '!' + byte(v % 85) + dest[i] = '!' + byte(v%85) v /= 85 } @@ -150,7 +150,7 @@ fn Decode(mut dest: []byte, src: []byte, flush: bool)!: (ndst: int, nsrc: int) { nb = 5 v = 0 | '!' <= b && b <= 'u': - v = v * 85 + u32(b - '!') + v = v*85 + u32(b-'!') nb++ |: error(DecodeError.Format) @@ -181,7 +181,7 @@ fn Decode(mut dest: []byte, src: []byte, flush: bool)!: (ndst: int, nsrc: int) { // The short encoding truncated the output value. // We have to assume the worst case values (digit 84) // in order to ensure that the top bits are correct. - v = v * 85 + 84 + v = v*85 + 84 } j = 0 for j < nb-1; j++ { @@ -259,7 +259,7 @@ impl encoder { ret &encoder{ w: w, buf: make([]byte, 4), - out: make([]byte, 1 << 10), + out: make([]byte, 1<<10), } } } @@ -320,8 +320,8 @@ impl decoder { static fn new(mut r: io::Reader): &decoder { ret &decoder{ r: r, - buf: make([]byte, 1 << 10), - outbuf: make([]byte, 1 << 10), + buf: make([]byte, 1<<10), + outbuf: make([]byte, 1<<10), } } } \ No newline at end of file diff --git a/std/encoding/ascii85/ascii85_test.jule b/std/encoding/ascii85/ascii85_test.jule index a5547ce39..c639c4a6d 100644 --- a/std/encoding/ascii85/ascii85_test.jule +++ b/std/encoding/ascii85/ascii85_test.jule @@ -15,7 +15,7 @@ static encodeDecodeMap = [ #test fn testEncode(t: &T) { - mut r := make([]byte, 1 << 8) + mut r := make([]byte, 1<<8) for _, case in encodeDecodeMap { n := Encode(r, case[1]) p := r[:n] @@ -35,7 +35,7 @@ fn testEncode(t: &T) { #test fn testDecode(t: &T) { - mut r := make([]byte, 1 << 8) + mut r := make([]byte, 1<<8) for _, case in encodeDecodeMap { n, _ := Decode(r, case[0], true) else { t.Fail() diff --git a/std/encoding/base32/base32.jule b/std/encoding/base32/base32.jule index 2643d926b..65b932546 100644 --- a/std/encoding/base32/base32.jule +++ b/std/encoding/base32/base32.jule @@ -22,7 +22,7 @@ fn encodeLen(n: int, pad: bool): int { if pad { ret (n + 4) / 5 << 3 } - ret n / 5 << 3 + (n % 5 << 3 + 4) / 5 + ret n/5<<3 + (n%5<<3+4)/5 } // Returns length of encoded bytes of b. @@ -36,7 +36,7 @@ fn DecodeLen(b: []byte): int { ret 0 } n := lenNoPad(b) - ret n >> 3 * 5 + n % 8 * 5 >> 3 + ret n>>3*5 + n%8*5>>3 } // Encodes source bytes into dest with standard base32 table. diff --git a/std/encoding/base64/base64.jule b/std/encoding/base64/base64.jule index b20e494b8..0e610f9a0 100644 --- a/std/encoding/base64/base64.jule +++ b/std/encoding/base64/base64.jule @@ -24,7 +24,7 @@ const paddingByte = '=' // Returns length of encoded bytes of b. fn EncodeLen(b: []byte, pad: bool): int { if !pad { - ret len(b) / 3 << 2 + (len(b) % 3 * 8 + 5) / 6 + ret len(b)/3<<2 + (len(b)%3*8+5)/6 } ret (len(b) + 2) / 3 << 2 } @@ -145,7 +145,7 @@ fn decode(&src: []byte): []byte { mut i := 0 for i < l; i += 4 { unsafe { - k := ip[p[i]] << 18 | ip[p[i+1]] << 12 | ip[p[i+2]] << 6 | ip[p[i+3]] + k := ip[p[i]]<<18 | ip[p[i+1]]<<12 | ip[p[i+2]]<<6 | ip[p[i+3]] *d = byte(k >> 16) d++ *d = byte(k >> 8 & 0xFF) @@ -156,7 +156,7 @@ fn decode(&src: []byte): []byte { } if pad1 { unsafe { - mut k := ip[p[l]] << 18 | ip[p[l+1]] << 12 + mut k := ip[p[l]]<<18 | ip[p[l+1]]<<12 *d = byte(k >> 16) if pad2 { d++ diff --git a/std/encoding/binary/big_endian.jule b/std/encoding/binary/big_endian.jule index 1dc2c224d..31be0f439 100644 --- a/std/encoding/binary/big_endian.jule +++ b/std/encoding/binary/big_endian.jule @@ -15,13 +15,13 @@ impl BigEndian { // Encodes unsigned 16-bit integer and appends to slice. static fn AppendU16(mut b: []byte, x: u16): []byte { ret append(b, - byte(x >> 8), + byte(x>>8), byte(x)) } // Decodes unsigned 16-bit integer from 2-bytes. static fn DecodeU16(b: []byte): u16 { - ret u16(b[1]) | u16(b[0]) << 8 + ret u16(b[1]) | u16(b[0])<<8 } // Encodes unsigned 32-bit integer into 4-bytes slice. @@ -35,15 +35,15 @@ impl BigEndian { // Encodes unsigned 32-bit integer and appends to slice. static fn AppendU32(mut b: []byte, x: u32): []byte { ret append(b, - byte(x >> 24), - byte(x >> 16), - byte(x >> 8), + byte(x>>24), + byte(x>>16), + byte(x>>8), byte(x)) } // Decodes unsigned 32-bit integer from 4-bytes. static fn DecodeU32(b: []byte): u32 { - ret u32(b[3]) | u32(b[2]) << 8 | u32(b[1]) << 16 | u32(b[0]) << 24 + ret u32(b[3]) | u32(b[2])<<8 | u32(b[1])<<16 | u32(b[0])<<24 } // Encodes unsigned 64-bit integer into 8-bytes slice. @@ -61,19 +61,19 @@ impl BigEndian { // Encodes unsigned 64-bit integer and appends to slice. static fn AppendU64(mut b: []byte, x: u64): []byte { ret append(b, - byte(x >> 56), - byte(x >> 48), - byte(x >> 40), - byte(x >> 32), - byte(x >> 24), - byte(x >> 16), - byte(x >> 8), + byte(x>>56), + byte(x>>48), + byte(x>>40), + byte(x>>32), + byte(x>>24), + byte(x>>16), + byte(x>>8), byte(x)) } // Decodes unsigned 64-bit integer from 8-bytes. static fn DecodeU64(b: []byte): u64 { - ret u64(b[7]) | u64(b[6]) << 8 | u64(b[5]) << 16 | u64(b[4]) << 24 | - u64(b[3]) << 32 | u64(b[2]) << 40 | u64(b[1]) << 48 | u64(b[0]) << 56 + ret u64(b[7]) | u64(b[6])<<8 | u64(b[5])<<16 | u64(b[4])<<24 | + u64(b[3])<<32 | u64(b[2])<<40 | u64(b[1])<<48 | u64(b[0])<<56 } } \ No newline at end of file diff --git a/std/encoding/binary/little_endian.jule b/std/encoding/binary/little_endian.jule index 08a000a25..a3966c37a 100644 --- a/std/encoding/binary/little_endian.jule +++ b/std/encoding/binary/little_endian.jule @@ -16,12 +16,12 @@ impl LittleEndian { static fn AppendU16(mut b: []byte, x: u16): []byte { ret append(b, byte(x), - byte(x >> 8)) + byte(x>>8)) } // Decodes unsigned 16-bit integer from 2-bytes. static fn DecodeU16(b: []byte): u16 { - ret u16(b[0]) | u16(b[1]) << 8 + ret u16(b[0]) | u16(b[1])<<8 } // Encodes unsigned 32-bit integer into 4-bytes slice. @@ -36,14 +36,14 @@ impl LittleEndian { static fn AppendU32(mut b: []byte, x: u32): []byte { ret append(b, byte(x), - byte(x >> 8), - byte(x >> 16), - byte(x >> 24)) + byte(x>>8), + byte(x>>16), + byte(x>>24)) } // Decodes unsigned 32-bit integer from 4-bytes. static fn DecodeU32(b: []byte): u32 { - ret u32(b[0]) | u32(b[1]) << 8 | u32(b[2]) << 16 | u32(b[3]) << 24 + ret u32(b[0]) | u32(b[1])<<8 | u32(b[2])<<16 | u32(b[3])<<24 } // Encodes unsigned 64-bit integer into 8-bytes slice. @@ -62,18 +62,18 @@ impl LittleEndian { static fn AppendU64(mut b: []byte, x: u64): []byte { ret append(b, byte(x), - byte(x >> 8), - byte(x >> 16), - byte(x >> 24), - byte(x >> 32), - byte(x >> 40), - byte(x >> 48), - byte(x >> 56)) + byte(x>>8), + byte(x>>16), + byte(x>>24), + byte(x>>32), + byte(x>>40), + byte(x>>48), + byte(x>>56)) } // Decodes unsigned 64-bit integer from 8-bytes. static fn DecodeU64(b: []byte): u64 { - ret u64(b[0]) | u64(b[1]) << 8 | u64(b[2]) << 16 | u64(b[3]) << 24 | - u64(b[4]) << 32 | u64(b[5]) << 40 | u64(b[6]) << 48 | u64(b[7]) << 56 + ret u64(b[0]) | u64(b[1])<<8 | u64(b[2])<<16 | u64(b[3])<<24 | + u64(b[4])<<32 | u64(b[5])<<40 | u64(b[6])<<48 | u64(b[7])<<56 } } \ No newline at end of file diff --git a/std/encoding/json/buffer.jule b/std/encoding/json/buffer.jule index 9847af861..2b7515991 100644 --- a/std/encoding/json/buffer.jule +++ b/std/encoding/json/buffer.jule @@ -62,7 +62,7 @@ impl buffer { panic("buffer too large") } else { // Add self.off to account for self.buf[:self.off] being sliced off the front. - self.buf = growSlice(self.buf[self.off:], self.off + n) + self.buf = growSlice(self.buf[self.off:], self.off+n) } // Restore self.off and len(self.buf). self.off = 0 diff --git a/std/encoding/json/decode.jule b/std/encoding/json/decode.jule index e5db54223..ee2f1a2ec 100644 --- a/std/encoding/json/decode.jule +++ b/std/encoding/json/decode.jule @@ -651,14 +651,14 @@ fn unquoteBytes(s: []byte): (t: []byte) { ret unsafe { *(&s) } } - mut b := make([]byte, len(s) + utf8::UTFMax << 1) + mut b := make([]byte, len(s)+utf8::UTFMax<<1) mut w := copy(b, s[:r]) for r < len(s) { // Out of room? Can only happen if s is full of // malformed UTF-8 and we're replacing each // byte with RuneError. if w >= len(b)-utf8::UTFMax<<1 { - mut nb := make([]byte, (len(b) + utf8::UTFMax) << 1) + mut nb := make([]byte, (len(b)+utf8::UTFMax)<<1) copy(nb, b[:w]) b = nb } @@ -738,7 +738,7 @@ fn unquoteBytes(s: []byte): (t: []byte) { fn decodeInt[T](mut &t: T, lit: []byte)! { // Use [unsafe::ByteStr] instead of casting. // The byte buffer will not change, so it's safe and efficient. - n := conv::ParseInt(unsafe::BytesStr(lit), 0xA, 1 << 6) else { error(JSONDecodeError.InvalidValue) } + n := conv::ParseInt(unsafe::BytesStr(lit), 0xA, 1<<6) else { error(JSONDecodeError.InvalidValue) } if n < i64(T.Min) || i64(T.Max) < n { error(JSONDecodeError.InvalidValue) } @@ -748,7 +748,7 @@ fn decodeInt[T](mut &t: T, lit: []byte)! { fn decodeUInt[T](mut &t: T, lit: []byte)! { // Use [unsafe::ByteStr] instead of casting. // The byte buffer will not change, so it's safe and efficient. - n := conv::ParseUint(unsafe::BytesStr(lit), 0xA, 1 << 6) else { error(JSONDecodeError.InvalidValue) } + n := conv::ParseUint(unsafe::BytesStr(lit), 0xA, 1<<6) else { error(JSONDecodeError.InvalidValue) } if u64(T.Max) < n { error(JSONDecodeError.InvalidValue) } @@ -758,7 +758,7 @@ fn decodeUInt[T](mut &t: T, lit: []byte)! { fn decodeFloat[T](mut &t: T, lit: []byte)! { // Use [unsafe::ByteStr] instead of casting. // The byte buffer will not change, so it's safe and efficient. - n := conv::ParseFloat(unsafe::BytesStr(lit), 1 << 6) else { error(JSONDecodeError.InvalidValue) } + n := conv::ParseFloat(unsafe::BytesStr(lit), 1<<6) else { error(JSONDecodeError.InvalidValue) } if f64(T.Max) < n { error(JSONDecodeError.InvalidValue) } diff --git a/std/encoding/json/encode.jule b/std/encoding/json/encode.jule index cb172e9bc..47a96938d 100644 --- a/std/encoding/json/encode.jule +++ b/std/encoding/json/encode.jule @@ -89,7 +89,7 @@ impl jsonEncoder { fmt = 'e' } } - s := conv::FmtFloat(f, fmt, -1, 1 << 6) + s := conv::FmtFloat(f, fmt, -1, 1<<6) mut sb := unsafe::StrBytes(s) if fmt == 'e' { // clean up e-09 to e-9 @@ -360,10 +360,10 @@ impl jsonEncoder { self.encodeUint(u64(t)) ret | f32: - self.encodeFloat(f64(t), 1 << 5) else { error(error) } + self.encodeFloat(f64(t), 1<<5) else { error(error) } ret | f64: - self.encodeFloat(t, 1 << 6) else { error(error) } + self.encodeFloat(t, 1<<6) else { error(error) } ret | bool: self.encodeBool(t) @@ -478,7 +478,7 @@ fn EncodeIndent[T](t: T, indent: str)!: []byte { } // Handle indentation. // See documentation of [encodeFlagType.Indent]. - mut buf := make([]byte, len(bytes) + encoder.total) + mut buf := make([]byte, len(bytes)+encoder.total) mut depth := 0 mut p := &buf[0] // Use raw pointer to mutate buffer efficiently. for _, b in bytes { diff --git a/std/fs/file.jule b/std/fs/file.jule index f921e179e..38a9f4070 100644 --- a/std/fs/file.jule +++ b/std/fs/file.jule @@ -53,7 +53,7 @@ impl File { // (before umask). If successful, methods on the returned File can // be used for I/O; the associated file descriptor has mode OFlag.Rdwr. static fn Create(path: str)!: &File { - ret File.Open(path, OFlag.Rdwr | OFlag.Create | OFlag.Trunc, 0666) else { error(error) } + ret File.Open(path, OFlag.Rdwr|OFlag.Create|OFlag.Trunc, 0666) else { error(error) } } // Reads bytes of file. @@ -103,7 +103,7 @@ impl File { // Since requires multiple system calls to complete, a failure mid-operation // can leave the file in a partially written state. static fn Write(path: str, data: []byte, perm: int)! { - mut f := File.Open(path, OFlag.Wronly | OFlag.Create | OFlag.Trunc, perm) else { error(error) } + mut f := File.Open(path, OFlag.Wronly|OFlag.Create|OFlag.Trunc, perm) else { error(error) } mut n := 0 for n < len(data) { n += f.Write(data[n:]) else { error(error) } diff --git a/std/hash/adler32/adler32.jule b/std/hash/adler32/adler32.jule index 83cbf238c..d7f36b96c 100644 --- a/std/hash/adler32/adler32.jule +++ b/std/hash/adler32/adler32.jule @@ -118,7 +118,7 @@ impl Adler32 { s2 %= mod unsafe { *(&p) = q } } - self.d = digest(s2 << 16 | s1) + self.d = digest(s2<<16 | s1) } fn Reset(mut self) { @@ -131,7 +131,7 @@ impl Adler32 { fn Sum(self, mut dest: []byte): []byte { s := u32(self.d) - ret append(dest, byte(s >> 24), byte(s >> 16), byte(s >> 8), byte(s)) + ret append(dest, byte(s>>24), byte(s>>16), byte(s>>8), byte(s)) } fn Sum32(self): u32 { ret u32(self.d) } diff --git a/std/hash/fnv/fnv.jule b/std/hash/fnv/fnv.jule index d87d8c453..13684b9bc 100644 --- a/std/hash/fnv/fnv.jule +++ b/std/hash/fnv/fnv.jule @@ -165,7 +165,7 @@ impl hash::Hash for fnv128 { fn Write(mut self, d: []byte)!: int { for _, c in d { mut s0, s1 := bits::Mul64(prime128Lower, self.s[1]) - s0 += self.s[1] << prime128Shift + prime128Lower * self.s[0] + s0 += self.s[1]<> 8)) + byte(v>>8)) } fn LeU32(b: []byte): u32 { - ret u32(b[3]) << 24 | u32(b[2]) << 16 | u32(b[1]) << 8 | u32(b[0]) + ret u32(b[3])<<24 | u32(b[2])<<16 | u32(b[1])<<8 | u32(b[0]) } fn LePutU32(mut b: []byte, v: u32) { @@ -67,14 +67,14 @@ fn LePutU32(mut b: []byte, v: u32) { fn LeAppendU32(mut b: []byte, v: u32): []byte { ret append(b, byte(v), - byte(v >> 8), - byte(v >> 16), - byte(v >> 24)) + byte(v>>8), + byte(v>>16), + byte(v>>24)) } fn LeU64(mut b: []byte): u64 { - ret u64(b[7]) << 56 | u64(b[6]) << 48 | u64(b[5]) << 40 | u64(b[4]) << 32 | - u64(b[3]) << 24 | u64(b[2]) << 16 | u64(b[1]) << 8 | u64(b[0]) + ret u64(b[7])<<56 | u64(b[6])<<48 | u64(b[5])<<40 | u64(b[4])<<32 | + u64(b[3])<<24 | u64(b[2])<<16 | u64(b[1])<<8 | u64(b[0]) } fn LePutU64(mut b: []byte, v: u64) { @@ -91,17 +91,17 @@ fn LePutU64(mut b: []byte, v: u64) { fn LeAppendU64(mut b: []byte, v: u64): []byte { ret append(b, byte(v), - byte(v >> 8), - byte(v >> 16), - byte(v >> 24), - byte(v >> 32), - byte(v >> 40), - byte(v >> 48), - byte(v >> 56)) + byte(v>>8), + byte(v>>16), + byte(v>>24), + byte(v>>32), + byte(v>>40), + byte(v>>48), + byte(v>>56)) } fn BeU16(b: []byte): u16 { - ret u16(b[1]) | u16(b[0]) << 8 + ret u16(b[1]) | u16(b[0])<<8 } fn BePutU16(mut b: []byte, v: u16) { @@ -111,12 +111,12 @@ fn BePutU16(mut b: []byte, v: u16) { fn BeAppendU16(mut b: []byte, v: u16): []byte { ret append(b, - byte(v >> 8), + byte(v>>8), byte(v)) } fn BeU32(b: []byte): u32 { - ret u32(b[0]) << 24 | u32(b[1]) << 16 | u32(b[2]) << 8 | u32(b[3]) + ret u32(b[0])<<24 | u32(b[1])<<16 | u32(b[2])<<8 | u32(b[3]) } fn BePutU32(mut b: []byte, v: u32) { @@ -128,15 +128,15 @@ fn BePutU32(mut b: []byte, v: u32) { fn BeAppendU32(mut b: []byte, v: u32): []byte { ret append(b, - byte(v >> 24), - byte(v >> 16), - byte(v >> 8), + byte(v>>24), + byte(v>>16), + byte(v>>8), byte(v)) } fn BeU64(b: []byte): u64 { - ret u64(b[7]) | u64(b[6]) << 8 | u64(b[5]) << 16 | u64(b[4]) << 24 | - u64(b[3]) << 32 | u64(b[2]) << 40 | u64(b[1]) << 48 | u64(b[0]) << 56 + ret u64(b[7]) | u64(b[6])<<8 | u64(b[5])<<16 | u64(b[4])<<24 | + u64(b[3])<<32 | u64(b[2])<<40 | u64(b[1])<<48 | u64(b[0])<<56 } fn BePutU64(mut b: []byte, v: u64) { @@ -152,12 +152,12 @@ fn BePutU64(mut b: []byte, v: u64) { fn BeAppendU64(mut b: []byte, v: u64): []byte { ret append(b, - byte(v >> 56), - byte(v >> 48), - byte(v >> 40), - byte(v >> 32), - byte(v >> 24), - byte(v >> 16), - byte(v >> 8), + byte(v>>56), + byte(v>>48), + byte(v>>40), + byte(v>>32), + byte(v>>24), + byte(v>>16), + byte(v>>8), byte(v)) } \ No newline at end of file diff --git a/std/internal/conv/atoi.jule b/std/internal/conv/atoi.jule index f6c8d81e0..2058e7274 100755 --- a/std/internal/conv/atoi.jule +++ b/std/internal/conv/atoi.jule @@ -44,10 +44,10 @@ fn Xbtoi(&s: []byte): (n: int, i: int, ok: bool) { n += int(s[i] - '0') } else if 'a' <= s[i] && s[i] <= 'f' { n <<= 4 - n += int(s[i] - 'a') + 10 + n += int(s[i]-'a') + 10 } else if 'A' <= s[i] && s[i] <= 'F' { n <<= 4 - n += int(s[i] - 'A') + 10 + n += int(s[i]-'A') + 10 } else { break } diff --git a/std/internal/conv/itoa.jule b/std/internal/conv/itoa.jule index 9367b51d5..783eca240 100755 --- a/std/internal/conv/itoa.jule +++ b/std/internal/conv/itoa.jule @@ -21,7 +21,7 @@ fn Utoa(mut x: uint): str { mut i := 0 for x >= 10 { q := x / 10 - buf[i] = byte('0' + x - q * 10) + buf[i] = byte('0' + x - q*10) i++ x = q } diff --git a/std/jule/constant/lit/bytes.jule b/std/jule/constant/lit/bytes.jule index f177c2230..66a1e759d 100644 --- a/std/jule/constant/lit/bytes.jule +++ b/std/jule/constant/lit/bytes.jule @@ -9,7 +9,7 @@ use utf8 for std::unicode::utf8 // Reports whether rune is byte actually. // In other words, whether rune is ACII. fn IsAscii(r: rune): bool { - const MaxAscii = 1 << 7 - 1 + const MaxAscii = 1<<7 - 1 ret r <= MaxAscii } diff --git a/std/jule/integrated/conv.jule b/std/jule/integrated/conv.jule index 33df96254..dcf733dea 100644 --- a/std/jule/integrated/conv.jule +++ b/std/jule/integrated/conv.jule @@ -89,12 +89,12 @@ unsafe fn BytePtrToStr(s: *byte): str { fn StrToBytes(s: str): []byte { for i, b in s { if b == 0 { - mut bytes := make([]byte, i + 1) + mut bytes := make([]byte, i+1) copy(bytes, s[:len(bytes)]) ret bytes } } - mut bytes := make([]byte, len(s) + 1) + mut bytes := make([]byte, len(s)+1) copy(bytes, s) ret bytes } \ No newline at end of file diff --git a/std/jule/parser/parser.jule b/std/jule/parser/parser.jule index 46253ada8..3ed8ba10d 100644 --- a/std/jule/parser/parser.jule +++ b/std/jule/parser/parser.jule @@ -1858,7 +1858,7 @@ impl parser { } else if tokens[ranges[n-1]].Id != left { self.pushWrongOrderCloseErr(t, tokens, ranges) } - self.removeRange(n - 1, t.Id, tokens, ranges) + self.removeRange(n-1, t.Id, tokens, ranges) } fn checkRanges(mut self, &tokens: []&Token) { diff --git a/std/jule/sema/builtin.jule b/std/jule/sema/builtin.jule index 7ac65cf82..5b0cb8f86 100644 --- a/std/jule/sema/builtin.jule +++ b/std/jule/sema/builtin.jule @@ -596,7 +596,7 @@ fn builtinCallerAppend(mut &e: &eval, mut &fc: &FnCallExpr, mut &d: &Data): &Dat mut slice := &SliceExprModel{ ElemKind: s.Elem, - Elems: make([]ExprModel, 0, len(fc.Args) - 1), + Elems: make([]ExprModel, 0, len(fc.Args)-1), } for (_, mut arg) in fc.Args[1:] { e1 = e.evalExpr(arg) @@ -1109,7 +1109,7 @@ fn builtinCallerStdJuleIntegratedEmit(mut &e: &eval, mut &fc: &FnCallExpr, mut & } if len(fc.Args) > 1 { - model.Exprs = make([]ExprModel, 0, len(fc.Args) - 1) + model.Exprs = make([]ExprModel, 0, len(fc.Args)-1) for (_, mut arg) in fc.Args[1:] { argd = e.eval1(arg) if argd == nil { diff --git a/std/jule/sema/eval.jule b/std/jule/sema/eval.jule index 295f6ec53..8bf767645 100644 --- a/std/jule/sema/eval.jule +++ b/std/jule/sema/eval.jule @@ -270,7 +270,7 @@ impl eval { base = 1 << 3 |: // Decimal - base = 1 << 3 + 2 + base = 1<<3 + 2 } mut d := new(Data) @@ -1280,7 +1280,7 @@ impl eval { } fn evalFnGenericFromIndexing(mut &self, mut &d: &Data, mut &i: &IndexingExpr) { - mut generics := make([]&TypeDecl, 0, 1 << 3) + mut generics := make([]&TypeDecl, 0, 1<<3) if !self.pushGenericsFromData(generics, i.Index) { d = nil ret diff --git a/std/jule/sema/scope.jule b/std/jule/sema/scope.jule index a02035575..94cd43d6d 100644 --- a/std/jule/sema/scope.jule +++ b/std/jule/sema/scope.jule @@ -803,7 +803,7 @@ impl scopeChecker { mut c := new(Conditional) self.scope.Stmts = append(self.scope.Stmts, c) - c.Elifs = make([]&If, 0, len(conditional.Tail) + 1) + c.Elifs = make([]&If, 0, len(conditional.Tail)+1) c.Elifs = append(c.Elifs, self.checkIf(conditional.Head)) for (_, mut elif) in conditional.Tail { diff --git a/std/jule/sema/sema.jule b/std/jule/sema/sema.jule index 3a0a4e6f2..e60510c0b 100644 --- a/std/jule/sema/sema.jule +++ b/std/jule/sema/sema.jule @@ -2882,7 +2882,7 @@ struct missingRetChecker { impl missingRetChecker { static fn new(): missingRetChecker { ret missingRetChecker{ - breaked: make([]uintptr, 1 << 4), + breaked: make([]uintptr, 1<<4), } } diff --git a/std/jule/types/bits.jule b/std/jule/types/bits.jule index 1ffeab248..3fc10829a 100644 --- a/std/jule/types/bits.jule +++ b/std/jule/types/bits.jule @@ -27,15 +27,15 @@ fn checkBit(v: str, bit: int, checker: bitChecker): bool { | len(v) == 1: ret true | strings::HasPrefix(v, "0x"): - ret checker(v[2:], 1 << 4, bit) // Hexadecimal + ret checker(v[2:], 1<<4, bit) // Hexadecimal | strings::HasPrefix(v, "0b"): - ret checker(v[2:], 1 << 1, bit) // Binary + ret checker(v[2:], 1<<1, bit) // Binary | strings::HasPrefix(v, "0o"): - ret checker(v[2:], 1 << 3, bit) // Octal + ret checker(v[2:], 1<<3, bit) // Octal | v[0] == '0': - ret checker(v[1:], 1 << 3, bit) // Octal + ret checker(v[1:], 1<<3, bit) // Octal |: - ret checker(v, 1 << 3 + 2, bit) // Decimal + ret checker(v, 1<<3+2, bit) // Decimal } } diff --git a/std/math/acosh.jule b/std/math/acosh.jule index 17bbe2fdd..55bd335ee 100644 --- a/std/math/acosh.jule +++ b/std/math/acosh.jule @@ -81,8 +81,8 @@ fn Acosh(x: f64): f64 { | x >= Large: ret Log(x) + Ln2 // x > 2**28 | x > 2: - ret Log(2 * x - 1 / (x + Sqrt(x * x - 1))) // 2**28 > x > 2 + ret Log(2*x - 1/(x+Sqrt(x*x-1))) // 2**28 > x > 2 } t := x - 1 - ret Log1p(t + Sqrt(2 * t + t * t)) // 2 >= x > 1 + ret Log1p(t + Sqrt(2*t+t*t)) // 2 >= x > 1 } \ No newline at end of file diff --git a/std/math/asin.jule b/std/math/asin.jule index e708affdf..cff875d80 100644 --- a/std/math/asin.jule +++ b/std/math/asin.jule @@ -60,9 +60,9 @@ fn Asin(mut x: f64): f64 { ret NaN() // special case } - mut temp := Sqrt(1 - x * x) + mut temp := Sqrt(1 - x*x) if x > 0.7 { - temp = Pi / 2 - satan(temp / x) + temp = Pi/2 - satan(temp/x) } else { temp = satan(x / temp) } @@ -77,4 +77,4 @@ fn Asin(mut x: f64): f64 { // // Special case is: // Acos(x) = NaN if x < -1 or x > 1 -fn Acos(x: f64): f64 { ret Pi / 2 - Asin(x) } \ No newline at end of file +fn Acos(x: f64): f64 { ret Pi/2 - Asin(x) } \ No newline at end of file diff --git a/std/math/asinh.jule b/std/math/asinh.jule index 266d94f89..87f803733 100644 --- a/std/math/asinh.jule +++ b/std/math/asinh.jule @@ -86,11 +86,11 @@ fn Asinh(mut x: f64): f64 { | x > Large: temp = Log(x) + Ln2 // |x| > 2**28 | x > 2: - temp = Log(2 * x + 1 / (Sqrt(x * x + 1) + x)) // 2**28 > |x| > 2.0 + temp = Log(2*x + 1/(Sqrt(x*x+1)+x)) // 2**28 > |x| > 2.0 | x < NearZero: temp = x // |x| < 2**-28 |: - temp = Log1p(x + x * x / (1 + Sqrt(1 + x * x))) // 2.0 > |x| > 2**-28 + temp = Log1p(x + x*x/(1+Sqrt(1+x*x))) // 2.0 > |x| > 2**-28 } if sign { temp = -temp diff --git a/std/math/atan.jule b/std/math/atan.jule index 5ea08fd24..a70a2a287 100644 --- a/std/math/atan.jule +++ b/std/math/atan.jule @@ -96,8 +96,8 @@ fn xatan(x: f64): f64 { const Q4 = +1.945506571482613964425e+02 mut z := x * x - z = z * ((((P0 * z + P1) * z + P2) * z + P3) * z + P4) / (((((z + Q0) * z + Q1) * z + Q2) * z + Q3) * z + Q4) - z = x * z + x + z = z * ((((P0*z+P1)*z+P2)*z+P3)*z + P4) / (((((z+Q0)*z+Q1)*z+Q2)*z+Q3)*z + Q4) + z = x*z + x ret z } @@ -111,9 +111,9 @@ fn satan(x: f64): f64 { ret xatan(x) } if x > tan3pio8 { - ret Pi / 2 - xatan(1 / x) + morebits + ret Pi/2 - xatan(1/x) + morebits } - ret Pi / 4 + xatan((x - 1) / (x + 1)) + 0.5 * morebits + ret Pi/4 + xatan((x-1)/(x+1)) + 0.5*morebits } // Returns the arctangent, in radians, of x. diff --git a/std/math/atan2.jule b/std/math/atan2.jule index 6d7f0240d..b5005b5ce 100644 --- a/std/math/atan2.jule +++ b/std/math/atan2.jule @@ -68,24 +68,24 @@ fn Atan2(y: f64, x: f64): f64 { } ret Copysign(Pi, y) | x == 0: - ret Copysign(Pi / 2, y) + ret Copysign(Pi/2, y) | IsInf(x, 0): if IsInf(x, 1) { match { | IsInf(y, 0): - ret Copysign(Pi / 4, y) + ret Copysign(Pi/4, y) |: ret Copysign(0, y) } } match { | IsInf(y, 0): - ret Copysign(3 * Pi / 4, y) + ret Copysign(3*Pi/4, y) |: ret Copysign(Pi, y) } | IsInf(y, 0): - ret Copysign(Pi / 2, y) + ret Copysign(Pi/2, y) } // Call atan and determine the quadrant. diff --git a/std/math/atanh.jule b/std/math/atanh.jule index b3f03809f..6220449e7 100644 --- a/std/math/atanh.jule +++ b/std/math/atanh.jule @@ -97,9 +97,9 @@ fn Atanh(mut x: f64): f64 { temp = x | x < 0.5: temp = x + x - temp = 0.5 * Log1p(temp + temp * x / (1 - x)) + temp = 0.5 * Log1p(temp+temp*x/(1-x)) |: - temp = 0.5 * Log1p((x + x) / (1 - x)) + temp = 0.5 * Log1p((x+x)/(1-x)) } if sign { temp = -temp diff --git a/std/math/big/bits.jule b/std/math/big/bits.jule index a10115525..f65f88262 100644 --- a/std/math/big/bits.jule +++ b/std/math/big/bits.jule @@ -177,7 +177,7 @@ fn add(&x: bits, &y: bits): (r: bits, carry: bit) { if i < len(y) { ybit = y[i] } - r = append(r, xbit ^ ybit ^ carry) + r = append(r, xbit^ybit^carry) carry = (xbit & ybit) | (xbit & carry) | (ybit & carry) } ret @@ -259,7 +259,7 @@ fn cloneBits(x: bits): bits { fn lsh(mut x: bits, y: int): bits { if y > 0 && len(x) > 0 { - mut x2 := make(bits, len(x) + y) + mut x2 := make(bits, len(x)+y) copy(x2[y:], x) ret x2 } @@ -328,7 +328,7 @@ fn basicSqr(mut &x: bits): bits { setU64(r, z) ret r } - + // Allocate enough space for full result of x*x. mut r := make(bits, n) @@ -447,7 +447,7 @@ fn karatsubaMul(mut x: bits, mut y: bits): bits { subRes(z1, z0) z1 = karatsubaLsh(z1, m) addRes(z1, z0) - addRes(z1, karatsubaLshC(z2, m << 1)) + addRes(z1, karatsubaLshC(z2, m<<1)) ret z1 } @@ -467,7 +467,7 @@ fn karatsubaSqr(mut x: bits): bits { subRes(z1, z0) z1 = karatsubaLsh(z1, m) addRes(z1, z0) - addRes(z1, karatsubaLshC(z2, m << 1)) + addRes(z1, karatsubaLshC(z2, m<<1)) ret z1 } diff --git a/std/math/big/conv.jule b/std/math/big/conv.jule index c5cb6d57c..1e98dc4aa 100644 --- a/std/math/big/conv.jule +++ b/std/math/big/conv.jule @@ -25,7 +25,7 @@ fn parseBinary(&s: str)!: bits { // All bits are zero. ret nil } - mut r := make(bits, 0, len(s) - j) + mut r := make(bits, 0, len(s)-j) mut k := len(s) - 1 for k >= j; k-- { match s[k] { @@ -43,7 +43,7 @@ fn parseBinary(&s: str)!: bits { // Parse bits from hexadecimal string. // Returns normalized bits. fn parseHex(&s: str)!: bits { - mut buf := make(bits, 0, len(s) * 4) + mut buf := make(bits, 0, len(s)*4) mut i := len(s) - 1 for i >= 0; i-- { h := s[i] @@ -91,7 +91,7 @@ fn parseHex(&s: str)!: bits { // Parse bits from octal string. // Returns normalized bits. fn parseOctal(&s: str)!: bits { - mut buf := make(bits, 0, len(s) * 3) + mut buf := make(bits, 0, len(s)*3) mut i := len(s) - 1 for i >= 0; i-- { match s[i] { @@ -126,14 +126,14 @@ fn parseDecimal(&s: str)!: []byte { error(BigError.Format) } } - mut buf := make([]byte, 0, len(s) * 4) + mut buf := make([]byte, 0, len(s)*4) loop: for { d := sb[len(sb)-1] - '0' - buf = append(buf, d % 2) + buf = append(buf, d%2) mut carry := byte(0) for i in sb { - t := carry * 10 + (sb[i] - '0') + t := carry*10 + (sb[i] - '0') sb[i] = '0' + (t >> 1) carry = t & 0b1 } @@ -178,7 +178,7 @@ fn formatDecimalPart(mut &buf: []byte, m: byte) { } fn formatDecimal(&b: bits): str { - mut buf := make([]byte, 1, len(b) >> 1 + 1) + mut buf := make([]byte, 1, len(b)>>1+1) buf[0] = '0' mut i := len(b) - 1 for i >= 0; i-- { @@ -191,8 +191,8 @@ fn formatDecimal(&b: bits): str { } fn formatOctal(&b: bits): str { - n := len(b) - len(b) % 3 - mut buf := make([]byte, 1, len(b) / 3 + 1) + n := len(b) - len(b)%3 + mut buf := make([]byte, 1, len(b)/3+1) mut i := 0 for i < n; i += 3 { buf = append(buf[:1], buf...) @@ -236,8 +236,8 @@ fn formatOctal(&b: bits): str { } fn formatHex(&b: bits): str { - n := len(b) - len(b) % 4 - mut buf := make([]byte, 1, len(b) >> 2 + 1) + n := len(b) - len(b)%4 + mut buf := make([]byte, 1, len(b)>>2+1) mut i := 0 for i < n; i += 4 { buf = append(buf[:1], buf...) diff --git a/std/math/big/nat.jule b/std/math/big/nat.jule index f33b2a374..ececc7832 100644 --- a/std/math/big/nat.jule +++ b/std/math/big/nat.jule @@ -32,23 +32,23 @@ impl nat { mut nat := nat.zero() const match type T { | i8: - nat.bits = make(bits, 1 << 3 - 1) + nat.bits = make(bits, 1<<3-1) | u8: - nat.bits = make(bits, 1 << 3) + nat.bits = make(bits, 1<<3) | i16: - nat.bits = make(bits, 1 << 4 - 1) + nat.bits = make(bits, 1<<4-1) | u16: - nat.bits = make(bits, 1 << 4) + nat.bits = make(bits, 1<<4) | i32: - nat.bits = make(bits, 1 << 5 - 1) + nat.bits = make(bits, 1<<5-1) | u32: - nat.bits = make(bits, 1 << 5) + nat.bits = make(bits, 1<<5) | i64: - nat.bits = make(bits, 1 << 6 - 1) + nat.bits = make(bits, 1<<6-1) | u64: - nat.bits = make(bits, 1 << 6) + nat.bits = make(bits, 1<<6) | int: - nat.bits = make(bits, _INT_SIZE - 1) + nat.bits = make(bits, _INT_SIZE-1) | uint: nat.bits = make(bits, _INT_SIZE) |: @@ -436,7 +436,7 @@ impl nat { // otherwise it converges to the correct z and stays there. // must be ≥ √x - mut z1 := make(bits, ((self.len() + 1) >> 1) + 1) + mut z1 := make(bits, ((self.len()+1)>>1)+1) z1[len(z1)-1] = 0b1 mut z2 := nat.zero().bits diff --git a/std/math/bits.jule b/std/math/bits.jule index 6f69a8ba1..5a89197c9 100644 --- a/std/math/bits.jule +++ b/std/math/bits.jule @@ -43,7 +43,7 @@ const mask = 0x7FF const shift = 64 - 11 - 1 const bias = 1023 const signMask = 1 << 63 -const fracMask = 1 << shift - 1 +const fracMask = 1<> 1 & (m0 & m) + x & (m0 & m) - x = x >> 2 & (m1 & m) + x & (m1 & m) - x = (x >> 4 + x) & (m2 & m) + x = x>>1&(m0&m) + x&(m0&m) + x = x>>2&(m1&m) + x&(m1&m) + x = (x>>4 + x) & (m2 & m) x += x >> 8 x += x >> 16 x += x >> 32 - ret int(x) & (1 << 7 - 1) + ret int(x) & (1<<7 - 1) } // --- rotate_left --- @@ -211,7 +211,7 @@ fn RotateLeft(x: uint, k: int): uint { fn RotateLeft8(x: u8, k: int): u8 { const n = 8 s := uint(k) & (n - 1) - ret x << s | x >> (n - s) + ret x<>(n-s) } // Returns the value of x rotated left by (k mod 16) bits. @@ -221,7 +221,7 @@ fn RotateLeft8(x: u8, k: int): u8 { fn RotateLeft16(x: u16, k: int): u16 { const n = 16 s := uint(k) & (n - 1) - ret x << s | x >> (n - s) + ret x<>(n-s) } // Returns the value of x rotated left by (k mod 32) bits. @@ -231,7 +231,7 @@ fn RotateLeft16(x: u16, k: int): u16 { fn RotateLeft32(x: u32, k: int): u32 { const n = 32 s := uint(k) & (n - 1) - ret x << s | x >> (n - s) + ret x<>(n-s) } // Returns the value of x rotated left by (k mod 64) bits. @@ -241,7 +241,7 @@ fn RotateLeft32(x: u32, k: int): u32 { fn RotateLeft64(x: u64, k: int): u64 { const n = 64 s := uint(k) & (n - 1) - ret x << s | x >> (n - s) + ret x<>(n-s) } // --- reverse --- @@ -261,24 +261,24 @@ fn Reverse8(x: u8): u8 { // Returns the value of x with its bits in reversed order. fn Reverse16(x: u16): u16 { - ret u16(rev8tab[x>>8]) | u16(rev8tab[x&0xff]) << 8 + ret u16(rev8tab[x>>8]) | u16(rev8tab[x&0xff])<<8 } // Returns the value of x with its bits in reversed order. fn Reverse32(mut x: u32): u32 { - const m = 1 << 32 - 1 - x = x >> 1 & (m0 & m) | x & (m0 & m) << 1 - x = x >> 2 & (m1 & m) | x & (m1 & m) << 2 - x = x >> 4 & (m2 & m) | x & (m2 & m) << 4 + const m = 1<<32 - 1 + x = x>>1&(m0&m) | x&(m0&m)<<1 + x = x>>2&(m1&m) | x&(m1&m)<<2 + x = x>>4&(m2&m) | x&(m2&m)<<4 ret ReverseBytes32(x) } // Returns the value of x with its bits in reversed order. fn Reverse64(mut x: u64): u64 { const m = 18446744073709551615 // 1<<64 - 1 - x = x >> 1 & (m0 & m) | x & (m0 & m) << 1 - x = x >> 2 & (m1 & m) | x & (m1 & m) << 2 - x = x >> 4 & (m2 & m) | x & (m2 & m) << 4 + x = x>>1&(m0&m) | x&(m0&m)<<1 + x = x>>2&(m1&m) | x&(m1&m)<<2 + x = x>>4&(m2&m) | x&(m2&m)<<4 ret ReverseBytes64(x) } @@ -298,16 +298,16 @@ fn ReverseBytes(x: uint): uint { // // This function's execution time does not depend on the inputs. fn ReverseBytes16(x: u16): u16 { - ret x >> 8 | x << 8 + ret x>>8 | x<<8 } // Returns the value of x with its bytes in reversed order. // // This function's execution time does not depend on the inputs. fn ReverseBytes32(mut x: u32): u32 { - const m = 1 << 32 - 1 - x = x >> 8 & (m3 & m) | x & (m3 & m) << 8 - ret x >> 16 | x << 16 + const m = 1<<32 - 1 + x = x>>8&(m3&m) | x&(m3&m)<<8 + ret x>>16 | x<<16 } // Returns the value of x with its bytes in reversed order. @@ -315,9 +315,9 @@ fn ReverseBytes32(mut x: u32): u32 { // This function's execution time does not depend on the inputs. fn ReverseBytes64(mut x: u64): u64 { const m = 18446744073709551615 // 1<<64 - 1 - x = x >> 8 & (m3 & m) | x & (m3 & m) << 8 - x = x >> 16 & (m4 & m) | x & (m4 & m) << 16 - ret x >> 32 | x << 32 + x = x>>8&(m3&m) | x&(m3&m)<<8 + x = x>>16&(m4&m) | x&(m4&m)<<16 + ret x>>32 | x<<32 } // --- len --- @@ -497,17 +497,17 @@ fn Mul32(x: u32, y: u32): (hi: u32, lo: u32) { // // This function's execution time does not depend on the inputs. fn Mul64(x: u64, y: u64): (hi: u64, lo: u64) { - const mask32 = 1 << 32 - 1 + const mask32 = 1<<32 - 1 x0 := x & mask32 x1 := x >> 32 y0 := y & mask32 y1 := y >> 32 w0 := x0 * y0 - t := x1 * y0 + w0 >> 32 + t := x1*y0 + w0>>32 mut w1 := t & mask32 w2 := t >> 32 w1 += x0 * y1 - hi = x1 * y1 + w2 + w1 >> 32 + hi = x1*y1 + w2 + w1>>32 lo = x * y ret } @@ -538,7 +538,7 @@ fn Div32(hi: u32, lo: u32, y: u32): (quo: u32, rem: u32) { if y != 0 && y <= hi { panic(overflowError) } - z := u64(hi) << 32 | u64(lo) + z := u64(hi)<<32 | u64(lo) quo, rem = u32(z / u64(y)), u32(z % u64(y)) ret } @@ -562,12 +562,12 @@ fn Div64(hi: u64, lo: u64, mut y: u64): (quo: u64, rem: u64) { yn1 := y >> 32 yn0 := y & mask32 - un32 := hi << s | lo >> (64 - s) + un32 := hi<>(64-s) un10 := lo << s un1 := un10 >> 32 un0 := un10 & mask32 mut q1 := un32 / yn1 - mut rhat := un32 - q1 * yn1 + mut rhat := un32 - q1*yn1 for q1 >= two32 || q1*yn0 > two32*rhat+un1 { q1-- @@ -577,9 +577,9 @@ fn Div64(hi: u64, lo: u64, mut y: u64): (quo: u64, rem: u64) { } } - un21 := un32 * two32 + un1 - q1 * y + un21 := un32*two32 + un1 - q1*y mut q0 := un21 / yn1 - rhat = un21 - q0 * yn1 + rhat = un21 - q0*yn1 for q0 >= two32 || q0*yn0 > two32*rhat+un0 { q0-- @@ -589,7 +589,7 @@ fn Div64(hi: u64, lo: u64, mut y: u64): (quo: u64, rem: u64) { } } - ret q1 * two32 + q0, (un21 * two32 + un0 - q0 * y) >> s + ret q1*two32 + q0, (un21*two32+un0-q0*y)>>s } // Returns the remainder of (hi, lo) divided by y. rem panics for @@ -606,7 +606,7 @@ fn Rem(hi: uint, lo: uint, y: uint): uint { // for y == 0 (division by zero) but, unlike div32, it doesn't panic // on a quotient overflow. fn Rem32(hi: u32, lo: u32, y: u32): u32 { - ret u32((u64(hi) << 32 | u64(lo)) % u64(y)) + ret u32((u64(hi)<<32 | u64(lo)) % u64(y)) } // Returns the remainder of (hi, lo) divided by y. rem64 panics @@ -619,6 +619,6 @@ fn Rem64(hi: u64, lo: u64, y: u64): u64 { // hi ≡ hi%y (mod y) // we have // hi<<64 + lo ≡ (hi%y)<<64 + lo (mod y) - _, rem := Div64(hi % y, lo, y) + _, rem := Div64(hi%y, lo, y) ret rem } \ No newline at end of file diff --git a/std/math/cbrt.jule b/std/math/cbrt.jule index 943ccd496..a4d6374b3 100644 --- a/std/math/cbrt.jule +++ b/std/math/cbrt.jule @@ -75,28 +75,28 @@ fn Cbrt(mut x: f64): f64 { } // rough cbrt to 5 bits - mut t := F64FromBits(F64Bits(x) / 3 + B1 << 32) + mut t := F64FromBits(F64Bits(x)/3 + B1<<32) if x < SmallestNormal { // subnormal number t = f64(1 << 54) // set t= 2**54 t *= x - t = F64FromBits(F64Bits(t) / 3 + B2 << 32) + t = F64FromBits(F64Bits(t)/3 + B2<<32) } // new cbrt to 23 bits mut r := t * t / x - mut s := C + r * t - t *= G + F / (s + E + D / s) + mut s := C + r*t + t *= G + F/(s+E+D/s) // chop to 22 bits, make larger than cbrt(x) - t = F64FromBits(F64Bits(t) & (0xFFFFFFFFC << 28) + 1 << 30) + t = F64FromBits(F64Bits(t)&(0xFFFFFFFFC<<28) + 1<<30) // one step newton iteration to 53 bits with error less than 0.667ulps s = t * t // t*t is exact r = x / s w := t + t r = (r - t) / (w + r) // r-s is exact - t = t + t * r + t = t + t*r // restore the sign bit if sign { diff --git a/std/math/cmplx/asin.jule b/std/math/cmplx/asin.jule index d5be2952d..4311d11c1 100644 --- a/std/math/cmplx/asin.jule +++ b/std/math/cmplx/asin.jule @@ -71,17 +71,17 @@ impl Cmplx { | math::IsNaN(self.Real()): ret self | math::IsInf(self.Real(), 0): - ret Cmplx.New(math::Copysign(math::Pi / 4, self.Real()), self.Imag()) + ret Cmplx.New(math::Copysign(math::Pi/4, self.Real()), self.Imag()) |: ret Cmplx.New(math::Copysign(0, self.Real()), self.Imag()) } | math::IsInf(self.Real(), 0): - ret Cmplx.New(math::Copysign(math::Pi / 2, self.Real()), math::Copysign(self.Real(), self.Imag())) + ret Cmplx.New(math::Copysign(math::Pi/2, self.Real()), math::Copysign(self.Real(), self.Imag())) } ct := Cmplx.New(-self.Imag(), self.Real()) // i * x xx := self.Mul(self) - x1 := Cmplx.New(1 - xx.Real(), -xx.Imag()) // 1 - x*x - x2 := x1.Sqrt() // x2 = sqrt(1 - x*x) + x1 := Cmplx.New(1-xx.Real(), -xx.Imag()) // 1 - x*x + x2 := x1.Sqrt() // x2 = sqrt(1 - x*x) w := ct.Add(x2).Log() ret Cmplx.New(w.Imag(), -w.Real()) // -i * w } @@ -96,7 +96,7 @@ impl Cmplx { | math::IsInf(self.Real(), 0): match { | math::IsInf(self.Imag(), 0): - ret Cmplx.New(self.Real(), math::Copysign(math::Pi / 4, self.Imag())) + ret Cmplx.New(self.Real(), math::Copysign(math::Pi/4, self.Imag())) | math::IsNaN(self.Imag()): ret self |: @@ -112,10 +112,10 @@ impl Cmplx { ret Cmplx.NaN() } | math::IsInf(self.Imag(), 0): - ret Cmplx.New(math::Copysign(self.Imag(), self.Real()), math::Copysign(math::Pi / 2, self.Imag())) + ret Cmplx.New(math::Copysign(self.Imag(), self.Real()), math::Copysign(math::Pi/2, self.Imag())) } xx := self.Mul(self) - x1 := Cmplx.New(1 + xx.Real(), xx.Imag()) // 1 + x*x + x1 := Cmplx.New(1+xx.Real(), xx.Imag()) // 1 + x*x ret self.Add(x1.Sqrt()).Log() // log(x + sqrt(1 + x*x)) } @@ -135,13 +135,13 @@ impl Cmplx { // Returns the inverse cosine of complex number. fn Acos(self): Cmplx { w := self.Asin() - ret Cmplx.New(math::Pi / 2 - w.Real(), -w.Imag()) + ret Cmplx.New(math::Pi/2-w.Real(), -w.Imag()) } // Returns the inverse hyperbolic cosine of complex number. fn Acosh(self): Cmplx { if self.IsZero() { - ret Cmplx.New(0, math::Copysign(math::Pi / 2, self.Imag())) + ret Cmplx.New(0, math::Copysign(math::Pi/2, self.Imag())) } w := self.Acos() if w.Imag() <= 0 { @@ -194,26 +194,26 @@ impl Cmplx { if math::IsNaN(self.Real()) { ret Cmplx.New(math::NaN(), math::Copysign(0, self.Imag())) } - ret Cmplx.New(math::Copysign(math::Pi / 2, self.Real()), math::Copysign(0, self.Imag())) + ret Cmplx.New(math::Copysign(math::Pi/2, self.Real()), math::Copysign(0, self.Imag())) | math::IsNaN(self.Real()) | math::IsNaN(self.Imag()): ret Cmplx.NaN() } x2 := self.Real() * self.Real() - a := 1 - x2 - self.Imag() * self.Imag() + a := 1 - x2 - self.Imag()*self.Imag() if a == 0 { ret Cmplx.NaN() } - mut t := 0.5 * math::Atan2(2 * self.Real(), a) + mut t := 0.5 * math::Atan2(2*self.Real(), a) w := reducePi(t) t = self.Imag() - 1 - b := x2 + t * t + b := x2 + t*t if b == 0 { ret Cmplx.NaN() } t = self.Imag() + 1 - c := (x2 + t * t) / b - ret Cmplx.New(w, 0.25 * math::Log(c)) + c := (x2 + t*t) / b + ret Cmplx.New(w, 0.25*math::Log(c)) } // Returns the inverse hyperbolic tangent of complex number. diff --git a/std/math/cmplx/cmplx.jule b/std/math/cmplx/cmplx.jule index bd77d6ea5..7d2a67c76 100644 --- a/std/math/cmplx/cmplx.jule +++ b/std/math/cmplx/cmplx.jule @@ -91,8 +91,8 @@ impl Cmplx { // Multiply complex numbers. fn MulAssign(mut self, c: Cmplx) { - real := self.Real() * c.Real() + self.Imag() * c.Imag() * -1 - imag := self.Real() * c.Imag() + self.Imag() * c.Real() + real := self.Real()*c.Real() + self.Imag()*c.Imag()*-1 + imag := self.Real()*c.Imag() + self.Imag()*c.Real() self.real = real self.imag = imag } @@ -108,14 +108,14 @@ impl Cmplx { // Divide complex numbers. // Assigns NaN complex number if denominator is zero. fn DivAssign(mut self, c: Cmplx) { - denominator := c.Real() * c.Real() + c.Imag() * c.Imag() + denominator := c.Real()*c.Real() + c.Imag()*c.Imag() if denominator == 0 { self.imag = math::NaN() self.real = math::NaN() ret } - numerator := self.Real() * c.Real() + self.Imag() * c.Imag() - self.imag = (self.Imag() * c.Real() - self.Real() * c.Imag()) / denominator + numerator := self.Real()*c.Real() + self.Imag()*c.Imag() + self.imag = (self.Imag()*c.Real() - self.Real()*c.Imag()) / denominator self.real = numerator / denominator } diff --git a/std/math/cmplx/exp.jule b/std/math/cmplx/exp.jule index 1f45b5709..701347b30 100644 --- a/std/math/cmplx/exp.jule +++ b/std/math/cmplx/exp.jule @@ -70,6 +70,6 @@ impl Cmplx { } r := math::Exp(self.Real()) s, c := math::Sincos(self.Imag()) - ret Cmplx.New(r * c, r * s) + ret Cmplx.New(r*c, r*s) } } \ No newline at end of file diff --git a/std/math/cmplx/log.jule b/std/math/cmplx/log.jule index d87da60ab..11d17be8f 100644 --- a/std/math/cmplx/log.jule +++ b/std/math/cmplx/log.jule @@ -64,6 +64,6 @@ impl Cmplx { // Returns the decimal logarithm of complex number. fn Log10(self): Cmplx { z := self.Log() - ret Cmplx.New(math::Log10E * z.Real(), math::Log10E * z.Imag()) + ret Cmplx.New(math::Log10E*z.Real(), math::Log10E*z.Imag()) } } \ No newline at end of file diff --git a/std/math/cmplx/pow.jule b/std/math/cmplx/pow.jule index a8d71341f..0a1141e22 100644 --- a/std/math/cmplx/pow.jule +++ b/std/math/cmplx/pow.jule @@ -80,6 +80,6 @@ impl Cmplx { theta += y.Imag() * math::Log(modulus) } s, c := math::Sincos(theta) - ret Cmplx.New(r * c, r * s) + ret Cmplx.New(r*c, r*s) } } \ No newline at end of file diff --git a/std/math/cmplx/rect.jule b/std/math/cmplx/rect.jule index 6d4e4c703..9ffea3cde 100644 --- a/std/math/cmplx/rect.jule +++ b/std/math/cmplx/rect.jule @@ -11,6 +11,6 @@ impl Cmplx { // Returns the complex number with polar coordinates r, θ. static fn Rect(r: f64, theta: f64): Cmplx { s, c := math::Sincos(theta) - ret Cmplx.New(r * c, r * s) + ret Cmplx.New(r*c, r*s) } } \ No newline at end of file diff --git a/std/math/cmplx/sin.jule b/std/math/cmplx/sin.jule index 9e491cd0d..6ddf0dcc5 100644 --- a/std/math/cmplx/sin.jule +++ b/std/math/cmplx/sin.jule @@ -69,7 +69,7 @@ impl Cmplx { } s, c := math::Sincos(self.Real()) sh, ch := sinhcosh(self.Imag()) - ret Cmplx.New(s * ch, c * sh) + ret Cmplx.New(s*ch, c*sh) } // Complex hyperbolic sine @@ -102,7 +102,7 @@ impl Cmplx { } s, c := math::Sincos(self.Imag()) sh, ch := sinhcosh(self.Real()) - ret Cmplx.New(c * sh, s * ch) + ret Cmplx.New(c*sh, s*ch) } // Complex circular cosine @@ -127,11 +127,11 @@ impl Cmplx { fn Cos(self): Cmplx { match { | self.Imag() == 0 && (math::IsInf(self.Real(), 0) || math::IsNaN(self.Real())): - ret Cmplx.New(math::NaN(), -self.Imag() * math::Copysign(0, self.Real())) + ret Cmplx.New(math::NaN(), -self.Imag()*math::Copysign(0, self.Real())) | math::IsInf(self.Imag(), 0): match { | self.Real() == 0: - ret Cmplx.New(math::Inf(1), -self.Real() * math::Copysign(0, self.Imag())) + ret Cmplx.New(math::Inf(1), -self.Real()*math::Copysign(0, self.Imag())) | math::IsInf(self.Real(), 0) | math::IsNaN(self.Real()): ret Cmplx.New(math::Inf(1), math::NaN()) } @@ -140,7 +140,7 @@ impl Cmplx { } s, c := math::Sincos(self.Real()) sh, ch := sinhcosh(self.Imag()) - ret Cmplx.New(c * ch, -s * sh) + ret Cmplx.New(c*ch, -s*sh) } // Complex hyperbolic cosine @@ -159,11 +159,11 @@ impl Cmplx { fn Cosh(self): Cmplx { match { | self.Real() == 0 && (math::IsInf(self.Imag(), 0) || math::IsNaN(self.Imag())): - ret Cmplx.New(math::NaN(), self.Real() * math::Copysign(0, self.Imag())) + ret Cmplx.New(math::NaN(), self.Real()*math::Copysign(0, self.Imag())) | math::IsInf(self.Real(), 0): match { | self.Imag() == 0: - ret Cmplx.New(math::Inf(1), self.Imag() * math::Copysign(0, self.Real())) + ret Cmplx.New(math::Inf(1), self.Imag()*math::Copysign(0, self.Real())) | math::IsInf(self.Imag(), 0) || math::IsNaN(self.Imag()): ret Cmplx.New(math::Inf(1), math::NaN()) } @@ -172,7 +172,7 @@ impl Cmplx { } s, c := math::Sincos(self.Imag()) sh, ch := sinhcosh(self.Real()) - ret Cmplx.New(c * ch, s * sh) + ret Cmplx.New(c*ch, s*sh) } } diff --git a/std/math/cmplx/sqrt.jule b/std/math/cmplx/sqrt.jule index 63153892b..8f8fda77d 100644 --- a/std/math/cmplx/sqrt.jule +++ b/std/math/cmplx/sqrt.jule @@ -95,12 +95,12 @@ impl Cmplx { mut r := math::Hypot(a, b) mut t := 0. if a > 0 { - t = math::Sqrt(0.5 * r + 0.5 * a) - r = scale * math::Abs((0.5 * b) / t) + t = math::Sqrt(0.5*r + 0.5*a) + r = scale * math::Abs((0.5*b)/t) t *= scale } else { - r = math::Sqrt(0.5 * r - 0.5 * a) - t = scale * math::Abs((0.5 * b) / r) + r = math::Sqrt(0.5*r - 0.5*a) + t = scale * math::Abs((0.5*b)/r) r *= scale } if b < 0 { diff --git a/std/math/cmplx/tan.jule b/std/math/cmplx/tan.jule index f86d4041f..82efe2518 100644 --- a/std/math/cmplx/tan.jule +++ b/std/math/cmplx/tan.jule @@ -67,18 +67,18 @@ impl Cmplx { | math::IsInf(self.Real(), 0) | math::IsNaN(self.Real()): ret Cmplx.New(math::Copysign(0, self.Real()), math::Copysign(1, self.Imag())) } - ret Cmplx.New(math::Copysign(0, math::Sin(2 * self.Real())), math::Copysign(1, self.Imag())) + ret Cmplx.New(math::Copysign(0, math::Sin(2*self.Real())), math::Copysign(1, self.Imag())) | self.Real() == 0 && math::IsNaN(self.Imag()): ret self } - mut d := math::Cos(2 * self.Real()) + math::Cosh(2 * self.Imag()) + mut d := math::Cos(2*self.Real()) + math::Cosh(2*self.Imag()) if math::Abs(d) < 0.25 { d = tanSeries(self) } if d == 0 { ret Cmplx.Inf(1) } - ret Cmplx.New(math::Sin(2 * self.Real()) / d, math::Sinh(2 * self.Imag()) / d) + ret Cmplx.New(math::Sin(2*self.Real())/d, math::Sinh(2*self.Imag())/d) } // Complex hyperbolic tangent @@ -101,15 +101,15 @@ impl Cmplx { | math::IsInf(self.Imag(), 0) | math::IsNaN(self.Imag()): ret Cmplx.New(math::Copysign(1, self.Real()), math::Copysign(0, self.Imag())) } - ret Cmplx.New(math::Copysign(1, self.Real()), math::Copysign(0, math::Sin(2 * self.Imag()))) + ret Cmplx.New(math::Copysign(1, self.Real()), math::Copysign(0, math::Sin(2*self.Imag()))) | self.Imag() == 0 && math::IsNaN(self.Real()): ret self } - d := math::Cosh(2 * self.Real()) + math::Cos(2 * self.Imag()) + d := math::Cosh(2*self.Real()) + math::Cos(2*self.Imag()) if d == 0 { ret Cmplx.Inf(1) } - ret Cmplx.New(math::Sinh(2 * self.Real()) / d, math::Sin(2 * self.Imag()) / d) + ret Cmplx.New(math::Sinh(2*self.Real())/d, math::Sin(2*self.Imag())/d) } // Complex circular cotangent @@ -139,14 +139,14 @@ impl Cmplx { // Returns the cotangent of complex number. fn Cot(self): Cmplx { - mut d := math::Cosh(2 * self.Imag()) - math::Cos(2 * self.Real()) + mut d := math::Cosh(2*self.Imag()) - math::Cos(2*self.Real()) if math::Abs(d) < 0.25 { d = tanSeries(self) } if d == 0 { ret Cmplx.Inf(1) } - ret Cmplx.New(math::Sin(2 * self.Real()) / d, -math::Sinh(2 * self.Imag()) / d) + ret Cmplx.New(math::Sin(2*self.Real())/d, -math::Sinh(2*self.Imag())/d) } } @@ -186,18 +186,18 @@ fn reducePi(mut x: f64): f64 { mut t := x / math::Pi t += 0.5 t = f64(i64(t)) // i64(t) = the multiple - ret ((x - t * PI1) - t * PI2) - t * PI3 + ret ((x - t*PI1) - t*PI2) - t*PI3 } // Must apply Payne-Hanek range reduction const MASK = 0x7FF const SHIFT = 64 - 11 - 1 const BIAS = 1023 - const FRAC_MASK = 1 << SHIFT - 1 + const FRAC_MASK = 1<> SHIFT & MASK) - BIAS - SHIFT + exp := int(ix>>SHIFT&MASK) - BIAS - SHIFT ix &= FRAC_MASK ix |= 1 << SHIFT @@ -230,7 +230,7 @@ fn reducePi(mut x: f64): f64 { // Use the exponent to extract the 3 appropriate u64 digits from mPi, // B ~ (z0, z1, z2), such that the product leading digit has the exponent -64. // Note, exp >= 50 since x >= REDUCE_THRESHOLD and exp < 971 for maximum f64. - digit, bitshift := uint(exp + 64) / 64, uint(exp + 64) % 64 + digit, bitshift := uint(exp+64) / 64, uint(exp+64) % 64 z0 := (mPi[digit] << bitshift) | (mPi[digit+1] >> (64 - bitshift)) z1 := (mPi[digit+1] << bitshift) | (mPi[digit+2] >> (64 - bitshift)) z2 := (mPi[digit+2] << bitshift) | (mPi[digit+3] >> (64 - bitshift)) diff --git a/std/math/copysign.jule b/std/math/copysign.jule index 61fcbda0d..d64c774b0 100644 --- a/std/math/copysign.jule +++ b/std/math/copysign.jule @@ -38,5 +38,5 @@ // Returns a value with the magnitude of f and the sign of sign. fn Copysign(f: f64, sign: f64): f64 { const SIGN_BIT = 1 << 63 - ret F64FromBits(F64Bits(f) & ^SIGN_BIT | F64Bits(sign) & SIGN_BIT) + ret F64FromBits(F64Bits(f)&^SIGN_BIT | F64Bits(sign)&SIGN_BIT) } \ No newline at end of file diff --git a/std/math/erf.jule b/std/math/erf.jule index a6bb9e090..11b426ae7 100644 --- a/std/math/erf.jule +++ b/std/math/erf.jule @@ -239,16 +239,16 @@ fn Erf(mut x: f64): f64 { mut temp := 0. if x < Small { // |x| < 2**-28 if x < VeryTiny { - temp = 0.125 * (8.0 * x + efx8 * x) // avoid underflow + temp = 0.125 * (8.0*x + efx8*x) // avoid underflow } else { - temp = x + efx * x + temp = x + efx*x } } else { z := x * x - r := pp0 + z * (pp1 + z * (pp2 + z * (pp3 + z * pp4))) - s := 1 + z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))) + r := pp0 + z*(pp1+z*(pp2+z*(pp3+z*pp4))) + s := 1 + z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))) y := r / s - temp = x + x * y + temp = x + x*y } if sign { ret -temp @@ -257,12 +257,12 @@ fn Erf(mut x: f64): f64 { } if x < 1.25 { // 0.84375 <= |x| < 1.25 s := x - 1 - P := pa0 + s * (pa1 + s * (pa2 + s * (pa3 + s * (pa4 + s * (pa5 + s * pa6))))) - Q := 1 + s * (qa1 + s * (qa2 + s * (qa3 + s * (qa4 + s * (qa5 + s * qa6))))) + P := pa0 + s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))) + Q := 1 + s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))) if sign { - ret -erx - P / Q + ret -erx - P/Q } - ret erx + P / Q + ret erx + P/Q } if x >= 6 { // inf > |x| >= 6 if sign { @@ -274,18 +274,18 @@ fn Erf(mut x: f64): f64 { mut R := 0. mut S := 0. if x < 1/0.35 { // |x| < 1 / 0.35 ~ 2.857143 - R = ra0 + s * (ra1 + s * (ra2 + s * (ra3 + s * (ra4 + s * (ra5 + s * (ra6 + s * ra7)))))) - S = 1 + s * (sa1 + s * (sa2 + s * (sa3 + s * (sa4 + s * (sa5 + s * (sa6 + s * (sa7 + s * sa8))))))) + R = ra0 + s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(ra5+s*(ra6+s*ra7)))))) + S = 1 + s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(sa5+s*(sa6+s*(sa7+s*sa8))))))) } else { // |x| >= 1 / 0.35 ~ 2.857143 - R = ra0 + s * (rb1 + s * (rb2 + s * (rb3 + s * (rb4 + s * (rb5 + s * rb6))))) - S = 1 + s * (sb1 + s * (sb2 + s * (sb3 + s * (sb4 + s * (sb5 + s * (sb6 + s * sb7)))))) + R = ra0 + s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6))))) + S = 1 + s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7)))))) } z := F64FromBits(F64Bits(x) & 0xffffffff00000000) // pseudo-single (20-bit) precision x - r := Exp(-z * z - 0.5625) * Exp((z - x) * (z + x) + R / S) + r := Exp(-z*z-0.5625) * Exp((z-x)*(z+x)+R/S) if sign { - ret r / x - 1 + ret r/x - 1 } - ret 1 - r / x + ret 1 - r/x } // Returns the complementary error function of x. @@ -316,13 +316,13 @@ fn Erfc(mut x: f64): f64 { temp = x } else { z := x * x - r := pp0 + z * (pp1 + z * (pp2 + z * (pp3 + z * pp4))) - s := 1 + z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))) + r := pp0 + z*(pp1+z*(pp2+z*(pp3+z*pp4))) + s := 1 + z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))) y := r / s if x < 0.25 { // |x| < 1/4 - temp = x + x * y + temp = x + x*y } else { - temp = 0.5 + (x * y + (x - 0.5)) + temp = 0.5 + (x*y + (x - 0.5)) } } if sign { @@ -332,31 +332,31 @@ fn Erfc(mut x: f64): f64 { } if x < 1.25 { // 0.84375 <= |x| < 1.25 s := x - 1 - P := pa0 + s * (pa1 + s * (pa2 + s * (pa3 + s * (pa4 + s * (pa5 + s * pa6))))) - Q := 1 + s * (qa1 + s * (qa2 + s * (qa3 + s * (qa4 + s * (qa5 + s * qa6))))) + P := pa0 + s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))) + Q := 1 + s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))) if sign { - ret 1 + erx + Q / P + ret 1 + erx + Q/P } - ret 1 - erx - Q / P + ret 1 - erx - Q/P } if x < 28 { // |x| < 28 s := 1 / (x * x) mut R := 0. mut S := 0. if x < 1/0.35 { // |x| < 1 / 0.35 ~ 2.857143 - R = ra0 + s * (ra1 + s * (ra2 + s * (ra3 + s * (ra4 + s * (ra5 + s * (ra6 + s * ra7)))))) - S = 1 + s * (sa1 + s * (sa2 + s * (sa3 + s * (sa4 + s * (sa5 + s * (sa6 + s * (sa7 + s * sa8))))))) + R = ra0 + s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(ra5+s*(ra6+s*ra7)))))) + S = 1 + s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(sa5+s*(sa6+s*(sa7+s*sa8))))))) } else { // |x| >= 1 / 0.35 ~ 2.857143 if sign && x > 6 { ret 2 // x < -6 } - R = rb0 + s * (rb1 + s * (rb2 + s * (rb3 + s * (rb4 + s * (rb5 + s * rb6))))) - S = 1 + s * (sb1 + s * (sb2 + s * (sb3 + s * (sb4 + s * (sb5 + s * (sb6 + s * sb7)))))) + R = rb0 + s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6))))) + S = 1 + s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7)))))) } z := F64FromBits(F64Bits(x) & 0xffffffff00000000) // pseudo-single (20-bit) precision x - r := Exp(-z * z - 0.5625) * Exp((z - x) * (z + x) + R / S) + r := Exp(-z*z-0.5625) * Exp((z-x)*(z+x)+R/S) if sign { - ret 2 - r / x + ret 2 - r/x } ret r / x } diff --git a/std/math/erfinv.jule b/std/math/erfinv.jule index 4673485e2..755bc4cbc 100644 --- a/std/math/erfinv.jule +++ b/std/math/erfinv.jule @@ -121,22 +121,22 @@ fn Erfinv(mut x: f64): f64 { mut ans := 0. if x <= 0.85 { // |x| <= 0.85 - r := 0.180625 - 0.25 * x * x - z1 := ((((((a7 * r + a6) * r + a5) * r + a4) * r + a3) * r + a2) * r + a1) * r + a0 - z2 := ((((((b7 * r + b6) * r + b5) * r + b4) * r + b3) * r + b2) * r + b1) * r + b0 + r := 0.180625 - 0.25*x*x + z1 := ((((((a7*r+a6)*r+a5)*r+a4)*r+a3)*r+a2)*r+a1)*r + a0 + z2 := ((((((b7*r+b6)*r+b5)*r+b4)*r+b3)*r+b2)*r+b1)*r + b0 ans = (x * z1) / z2 } else { mut z1 := 0. mut z2 := 0. - mut r := Sqrt(Ln2 - Log(1.0 - x)) + mut r := Sqrt(Ln2 - Log(1.0-x)) if r <= 5.0 { r -= 1.6 - z1 = ((((((c7 * r + c6) * r + c5) * r + c4) * r + c3) * r + c2) * r + c1) * r + c0 - z2 = ((((((d7 * r + d6) * r + d5) * r + d4) * r + d3) * r + d2) * r + d1) * r + d0 + z1 = ((((((c7*r+c6)*r+c5)*r+c4)*r+c3)*r+c2)*r+c1)*r + c0 + z2 = ((((((d7*r+d6)*r+d5)*r+d4)*r+d3)*r+d2)*r+d1)*r + d0 } else { r -= 5.0 - z1 = ((((((e7 * r + e6) * r + e5) * r + e4) * r + e3) * r + e2) * r + e1) * r + e0 - z2 = ((((((f7 * r + f6) * r + f5) * r + f4) * r + f3) * r + f2) * r + f1) * r + f0 + z1 = ((((((e7*r+e6)*r+e5)*r+e4)*r+e3)*r+e2)*r+e1)*r + e0 + z2 = ((((((f7*r+f6)*r+f5)*r+f4)*r+f3)*r+f2)*r+f1)*r + f0 } ans = z1 / z2 } diff --git a/std/math/exp.jule b/std/math/exp.jule index 4e04354e9..a92bf2673 100644 --- a/std/math/exp.jule +++ b/std/math/exp.jule @@ -146,11 +146,11 @@ fn Exp(x: f64): f64 { mut k := 0 match { | x < 0: - k = int(Log2E * x - 0.5) + k = int(Log2E*x - 0.5) | x > 0: - k = int(Log2E * x + 0.5) + k = int(Log2E*x + 0.5) } - hi := x - f64(k) * Ln2Hi + hi := x - f64(k)*Ln2Hi lo := f64(k) * Ln2Lo // compute @@ -205,8 +205,8 @@ fn expmulti(hi: f64, lo: f64, k: int): f64 { r := hi - lo t := r * r - c := r - t * (p1 + t * (p2 + t * (p3 + t * (p4 + t * p5)))) - y := 1 - ((lo - (r * c) / (2 - c)) - hi) + c := r - t*(p1+t*(p2+t*(p3+t*(p4+t*p5)))) + y := 1 - ((lo - (r*c)/(2-c)) - hi) // TODO(rsc): make sure ldexp can handle boundary k ret Ldexp(y, k) } \ No newline at end of file diff --git a/std/math/expm1.jule b/std/math/expm1.jule index c8506904f..2a9ba4211 100644 --- a/std/math/expm1.jule +++ b/std/math/expm1.jule @@ -212,12 +212,12 @@ fn Expm1(mut x: f64): f64 { } } else { if !sign { - k = int(INV_LN2 * x + 0.5) + k = int(INV_LN2*x + 0.5) } else { - k = int(INV_LN2 * x - 0.5) + k = int(INV_LN2*x - 0.5) } t := f64(k) - hi = x - t * LN2_HI // t * LN2_HI is exact here + hi = x - t*LN2_HI // t * LN2_HI is exact here lo = t * LN2_LO } x = hi - lo @@ -231,36 +231,36 @@ fn Expm1(mut x: f64): f64 { // x is now in primary range hfx := 0.5 * x hxs := x * hfx - r1 := 1 + hxs * (Q1 + hxs * (Q2 + hxs * (Q3 + hxs * (Q4 + hxs * Q5)))) - mut t := 3 - r1 * hfx - mut e := hxs * ((r1 - t) / (6.0 - x * t)) + r1 := 1 + hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))) + mut t := 3 - r1*hfx + mut e := hxs * ((r1 - t) / (6.0 - x*t)) if k == 0 { - ret x - (x * e - hxs) // c is 0 + ret x - (x*e - hxs) // c is 0 } - e = (x * (e - c) - c) + e = (x*(e-c) - c) e -= hxs match { | k == -1: - ret 0.5 * (x - e) - 0.5 + ret 0.5*(x-e) - 0.5 | k == 1: if x < -0.25 { ret -2 * (e - (x + 0.5)) } - ret 1 + 2 * (x - e) + ret 1 + 2*(x-e) | k <= -2 | k > 56: // suffice to return exp(x)-1 mut y := 1 - (e - x) - y = F64FromBits(F64Bits(y) + u64(k) << 52) // add k to y's exponent + y = F64FromBits(F64Bits(y) + u64(k)<<52) // add k to y's exponent ret y - 1 } if k < 20 { t = F64FromBits(u64(0x3ff0000000000000 - (0x20000000000000 >> uint(k)))) // t=1-2**-k mut y := t - (e - x) - y = F64FromBits(F64Bits(y) + u64(k) << 52) // add k to y's exponent + y = F64FromBits(F64Bits(y) + u64(k)<<52) // add k to y's exponent ret y } - t = F64FromBits(u64(0x3ff - k) << 52) // 2**-k + t = F64FromBits(u64(0x3ff-k) << 52) // 2**-k mut y := x - (e + t) y++ - y = F64FromBits(F64Bits(y) + u64(k) << 52) // add k to y's exponent + y = F64FromBits(F64Bits(y) + u64(k)<<52) // add k to y's exponent ret y } \ No newline at end of file diff --git a/std/math/floor.jule b/std/math/floor.jule index 74516d9d6..b0c34653a 100644 --- a/std/math/floor.jule +++ b/std/math/floor.jule @@ -95,7 +95,7 @@ fn Round(x: f64): f64 { // ret t // } mut bits := F64Bits(x) - mut e := uint(bits >> shift) & mask + mut e := uint(bits>>shift) & mask if e < bias { // Round abs(x) < 1 including denormals. bits &= signMask // +-0 @@ -134,7 +134,7 @@ fn RoundEven(x: f64): f64 { // ret t // } mut bits := F64Bits(x) - mut e := uint(bits >> shift) & mask + mut e := uint(bits>>shift) & mask if e >= bias { // Round abs(x) >= 1. // - Large numbers without fractional components, infinity, and NaN are unchanged. @@ -142,11 +142,11 @@ fn RoundEven(x: f64): f64 { // number is even or odd (respectively). const halfMinusUlp = (1 << (shift - 1)) - 1 e -= bias - bits += (halfMinusUlp + (bits >> (shift - e)) & 1) >> e + bits += (halfMinusUlp + (bits>>(shift-e))&1) >> e bits &= ^(fracMask >> e) } else if e == bias-1 && bits&fracMask != 0 { // Round 0.5 < abs(x) < 1. - bits = bits & signMask | uvone // +-1 + bits = bits&signMask | uvone // +-1 } else { // Round abs(x) <= 0.5 including denormals. bits &= signMask // +-0 diff --git a/std/math/fma.jule b/std/math/fma.jule index 15ee588d1..131c35d64 100644 --- a/std/math/fma.jule +++ b/std/math/fma.jule @@ -56,7 +56,7 @@ fn nonzero(x: u64): u64 { } fn shl(u1: u64, u2: u64, n: uint): (r1: u64, r2: u64) { - r1 = u1 << n | u2 >> (64 - n) | u2 << (n - 64) + r1 = u1<>(64-n) | u2<<(n-64) r2 = u2 << n ret } @@ -81,10 +81,10 @@ fn shrcompress(u1: u64, u2: u64, n: uint): (r1: u64, r2: u64) { ret 0, nonzero(u1 | u2) | n < 64: r1, r2 = shr(u1, u2, n) - r2 |= nonzero(u2 & (1 << n - 1)) + r2 |= nonzero(u2 & (1<> 63) - exp = i32(b >> 52) & mask + exp = i32(b>>52) & mask mantissa = b & fracMask if exp == 0 { @@ -124,7 +124,7 @@ fn FMA(x: f64, y: f64, z: f64): f64 { // inf or NaN or zero involved. At most one rounding will occur. if x == 0.0 || y == 0.0 || z == 0.0 || bx&uvinf == uvinf || by&uvinf == uvinf { - ret x * y + z + ret x*y + z } // Handle non-finite z separately. Evaluating x*y+z where // x and y are finite, but z is infinite, should always result in z. @@ -145,7 +145,7 @@ fn FMA(x: f64, y: f64, z: f64): f64 { // pm1:pm2 is the double-word mantissa for the product p. // Shift left to leave top bit in product. Effectively // shifts the 106-bit product to the left by 21. - mut pm1, mut pm2 := bits::Mul64(xm << 10, ym << 11) + mut pm1, mut pm2 := bits::Mul64(xm<<10, ym<<11) mut zm1, mut zm2 := zm << 10, u64(0) mut ps := xs ^ ys // product sign @@ -160,7 +160,7 @@ fn FMA(x: f64, y: f64, z: f64): f64 { } // Align significands - zm1, zm2 = shrcompress(zm1, zm2, uint(pe - ze)) + zm1, zm2 = shrcompress(zm1, zm2, uint(pe-ze)) // Compute resulting significands, normalizing if necessary. mut m := u64(0) @@ -170,28 +170,28 @@ fn FMA(x: f64, y: f64, z: f64): f64 { pm2, c = bits::Add64(pm2, zm2, 0) pm1, _ = bits::Add64(pm1, zm1, c) pe -= i32(^pm1 >> 63) - pm1, m = shrcompress(pm1, pm2, uint(64 + pm1 >> 63)) + pm1, m = shrcompress(pm1, pm2, uint(64+pm1>>63)) } else { // Subtracting (pm1:pm2) - (zm1:zm2) pm2, c = bits::Sub64(pm2, zm2, 0) pm1, _ = bits::Sub64(pm1, zm1, c) nz := lz(pm1, pm2) pe -= nz - m, pm2 = shl(pm1, pm2, uint(nz - 1)) + m, pm2 = shl(pm1, pm2, uint(nz-1)) m |= nonzero(pm2) } // Round and break ties to even if pe > 1022+bias || pe == 1022+bias && (m+1<<9)>>63 == 1 { // rounded value overflows exponent range - ret F64FromBits(u64(ps) << 63 | uvinf) + ret F64FromBits(u64(ps)<<63 | uvinf) } if pe < 0 { n := uint(-pe) - m = m >> n | nonzero(m & (1 << n - 1)) + m = m>>n | nonzero(m&(1<> 10) & ^zero((m & (1 << 10 - 1)) ^ 1 << 9) + m = ((m + 1<<9) >> 10) & ^zero((m & (1<<10 - 1)) ^ 1<<9) pe &= -i32(nonzero(m)) - ret F64FromBits(u64(ps) << 63 + u64(pe) << 52 + m) + ret F64FromBits(u64(ps)<<63 + u64(pe)<<52 + m) } \ No newline at end of file diff --git a/std/math/frexp.jule b/std/math/frexp.jule index 1ab03b8dc..fc34a3eb2 100644 --- a/std/math/frexp.jule +++ b/std/math/frexp.jule @@ -54,7 +54,7 @@ fn Frexp(mut f: f64): (frac: f64, exp: int) { } f, exp = normalize(f) mut x := F64Bits(f) - exp += int((x >> shift) & mask) - bias + 1 + exp += int((x>>shift)&mask) - bias + 1 x = x & ^(mask << shift) x |= (-1 + bias) << shift frac = F64FromBits(x) diff --git a/std/math/gamma.jule b/std/math/gamma.jule index b73d21cf8..a4361cba2 100644 --- a/std/math/gamma.jule +++ b/std/math/gamma.jule @@ -135,14 +135,14 @@ fn stirling(x: f64): (f64, f64) { const SqrtTwoPi = 2.506628274631000502417 const MaxStirling = 143.01608 mut w := 1 / x - w = 1 + w * ((((gams[0] * w + gams[1]) * w + gams[2]) * w + gams[3]) * w + gams[4]) + w = 1 + w*((((gams[0]*w+gams[1])*w+gams[2])*w+gams[3])*w+gams[4]) mut y1 := Exp(x) mut y2 := 1.0 if x > MaxStirling { // avoid Pow() overflow - v := Pow(x, 0.5 * x - 0.25) + v := Pow(x, 0.5*x-0.25) y1, y2 = v, v / y1 } else { - y1 = Pow(x, x - 0.5) / y1 + y1 = Pow(x, x-0.5) / y1 } ret y1, SqrtTwoPi * w * y2 } @@ -190,7 +190,7 @@ fn Gamma(mut x: f64): f64 { p = p + 1 z = q - p } - z = q * Sin(Pi * z) + z = q * Sin(Pi*z) if z == 0 { ret Inf(signgam) } @@ -231,15 +231,15 @@ fn Gamma(mut x: f64): f64 { } x = x - 2 - p = (((((x * gamp[0] + gamp[1]) * x + gamp[2]) * x + gamp[3]) * x + gamp[4]) * x + gamp[5]) * x + gamp[6] - q = ((((((x * gamq[0] + gamq[1]) * x + gamq[2]) * x + gamq[3]) * x + gamq[4]) * x + gamq[5]) * x + gamq[6]) * x + gamq[7] + p = (((((x*gamp[0]+gamp[1])*x+gamp[2])*x+gamp[3])*x+gamp[4])*x+gamp[5])*x + gamp[6] + q = ((((((x*gamq[0]+gamq[1])*x+gamq[2])*x+gamq[3])*x+gamq[4])*x+gamq[5])*x+gamq[6])*x + gamq[7] ret z * p / q small: if x == 0 { ret Inf(1) } - ret z / ((1 + euler * x) * x) + ret z / ((1 + euler*x) * x) } fn isNegInt(x: f64): bool { diff --git a/std/math/hypot.jule b/std/math/hypot.jule index a91df26e3..c65839575 100644 --- a/std/math/hypot.jule +++ b/std/math/hypot.jule @@ -63,5 +63,5 @@ fn Hypot(mut p: f64, mut q: f64): f64 { ret 0 } q = q / p - ret p * Sqrt(1 + q * q) + ret p * Sqrt(1+q*q) } \ No newline at end of file diff --git a/std/math/j0.jule b/std/math/j0.jule index b33da7013..5392e3c2b 100644 --- a/std/math/j0.jule +++ b/std/math/j0.jule @@ -152,7 +152,7 @@ fn J0(mut x: f64): f64 { } else { u := pzero(x) v := qzero(x) - z = (1 / SqrtPi) * (u * cc - v * ss) / Sqrt(x) + z = (1 / SqrtPi) * (u*cc - v*ss) / Sqrt(x) } ret z // |x| >= 2.0 } @@ -160,16 +160,16 @@ fn J0(mut x: f64): f64 { if x < TWO_M27 { ret 1 // |x| < ~7.4506e-9 } - ret 1 - 0.25 * x * x // ~7.4506e-9 < |x| < ~1.2207e-4 + ret 1 - 0.25*x*x // ~7.4506e-9 < |x| < ~1.2207e-4 } z := x * x - r := z * (R02 + z * (R03 + z * (R04 + z * R05))) - s := 1 + z * (S01 + z * (S02 + z * (S03 + z * S04))) + r := z * (R02 + z*(R03+z*(R04+z*R05))) + s := 1 + z*(S01+z*(S02+z*(S03+z*S04))) if x < 1 { - ret 1 + z * (-0.25 + (r / s)) // |x| < 1.00 + ret 1 + z*(-0.25+(r/s)) // |x| < 1.00 } u := 0.5 * x - ret (1 + u) * (1 - u) + z * (r / s) // 1.0 < |x| < 2.0 + ret (1+u)*(1-u) + z*(r/s) // 1.0 < |x| < 2.0 } // Returns the order-zero Bessel function of the second kind. @@ -237,17 +237,17 @@ fn Y0(x: f64): f64 { } else { u := pzero(x) v := qzero(x) - z = (1 / SqrtPi) * (u * ss + v * cc) / Sqrt(x) + z = (1 / SqrtPi) * (u*ss + v*cc) / Sqrt(x) } ret z // |x| >= 2.0 } if x <= TWO_M27 { - ret U00 + (2 / Pi) * Log(x) // |x| < ~7.4506e-9 + ret U00 + (2/Pi)*Log(x) // |x| < ~7.4506e-9 } z := x * x - u := U00 + z * (U01 + z * (U02 + z * (U03 + z * (U04 + z * (U05 + z * U06))))) - v := 1 + z * (V01 + z * (V02 + z * (V03 + z * V04))) - ret u / v + (2 / Pi) * J0(x) * Log(x) // ~7.4506e-9 < |x| < 2.0 + u := U00 + z*(U01+z*(U02+z*(U03+z*(U04+z*(U05+z*U06))))) + v := 1 + z*(V01+z*(V02+z*(V03+z*V04))) + ret u/v + (2/Pi)*J0(x)*Log(x) // ~7.4506e-9 < |x| < 2.0 } // The asymptotic expansions of pzero is @@ -345,9 +345,9 @@ fn pzero(x: f64): f64 { } unsafe { z := 1 / (x * x) - r := (*p)[0] + z * ((*p)[1] + z * ((*p)[2] + z * ((*p)[3] + z * ((*p)[4] + z * (*p)[5])))) - s := 1 + z * ((*q)[0] + z * ((*q)[1] + z * ((*q)[2] + z * ((*q)[3] + z * (*q)[4])))) - ret 1 + r / s + r := (*p)[0] + z*((*p)[1]+z*((*p)[2]+z*((*p)[3]+z*((*p)[4]+z*(*p)[5])))) + s := 1 + z*((*q)[0]+z*((*q)[1]+z*((*q)[2]+z*((*q)[3]+z*(*q)[4])))) + ret 1 + r/s } } @@ -450,8 +450,8 @@ fn qzero(x: f64): f64 { } unsafe { z := 1 / (x * x) - r := (*p)[0] + z * ((*p)[1] + z * ((*p)[2] + z * ((*p)[3] + z * ((*p)[4] + z * (*p)[5])))) - s := 1 + z * ((*q)[0] + z * ((*q)[1] + z * ((*q)[2] + z * ((*q)[3] + z * ((*q)[4] + z * (*q)[5]))))) - ret (-0.125 + r / s) / x + r := (*p)[0] + z*((*p)[1]+z*((*p)[2]+z*((*p)[3]+z*((*p)[4]+z*(*p)[5])))) + s := 1 + z*((*q)[0]+z*((*q)[1]+z*((*q)[2]+z*((*q)[3]+z*((*q)[4]+z*(*q)[5]))))) + ret (-0.125 + r/s) / x } } \ No newline at end of file diff --git a/std/math/j1.jule b/std/math/j1.jule index d57cfac6e..a3f630eac 100644 --- a/std/math/j1.jule +++ b/std/math/j1.jule @@ -152,7 +152,7 @@ fn J1(mut x: f64): f64 { } else { u := pone(x) v := qone(x) - z = (1 / SqrtPi) * (u * cc - v * ss) / Sqrt(x) + z = (1 / SqrtPi) * (u*cc - v*ss) / Sqrt(x) } if sign { ret -z @@ -164,10 +164,10 @@ fn J1(mut x: f64): f64 { ret 0.5 * x // inexact if x!=0 necessary } mut z := x * x - mut r := z * (R00 + z * (R01 + z * (R02 + z * R03))) - s := 1.0 + z * (S01 + z * (S02 + z * (S03 + z * (S04 + z * S05)))) + mut r := z * (R00 + z*(R01+z*(R02+z*R03))) + s := 1.0 + z*(S01+z*(S02+z*(S03+z*(S04+z*S05)))) r *= x - z = 0.5 * x + r / s + z = 0.5*x + r/s if sign { ret -z } @@ -235,7 +235,7 @@ fn Y1(x: f64): f64 { } else { u := pone(x) v := qone(x) - z = (1 / SqrtPi) * (u * ss + v * cc) / Sqrt(x) + z = (1 / SqrtPi) * (u*ss + v*cc) / Sqrt(x) } ret z } @@ -243,9 +243,9 @@ fn Y1(x: f64): f64 { ret -(2 / Pi) / x } z := x * x - u := U00 + z * (U01 + z * (U02 + z * (U03 + z * U04))) - v := 1 + z * (V00 + z * (V01 + z * (V02 + z * (V03 + z * V04)))) - ret x * (u / v) + (2 / Pi) * (J1(x) * Log(x) - 1 / x) + u := U00 + z*(U01+z*(U02+z*(U03+z*U04))) + v := 1 + z*(V00+z*(V01+z*(V02+z*(V03+z*V04)))) + ret x*(u/v) + (2/Pi)*(J1(x)*Log(x)-1/x) } // For x >= 8, the asymptotic expansions of pone is @@ -343,9 +343,9 @@ fn pone(x: f64): f64 { } unsafe { z := 1 / (x * x) - r := (*p)[0] + z * ((*p)[1] + z * ((*p)[2] + z * ((*p)[3] + z * ((*p)[4] + z * (*p)[5])))) - s := 1.0 + z * ((*q)[0] + z * ((*q)[1] + z * ((*q)[2] + z * ((*q)[3] + z * (*q)[4])))) - ret 1 + r / s + r := (*p)[0] + z*((*p)[1]+z*((*p)[2]+z*((*p)[3]+z*((*p)[4]+z*(*p)[5])))) + s := 1.0 + z*((*q)[0]+z*((*q)[1]+z*((*q)[2]+z*((*q)[3]+z*(*q)[4])))) + ret 1 + r/s } } @@ -448,8 +448,8 @@ fn qone(x: f64): f64 { } unsafe { z := 1 / (x * x) - r := (*p)[0] + z * ((*p)[1] + z * ((*p)[2] + z * ((*p)[3] + z * ((*p)[4] + z * (*p)[5])))) - s := 1 + z * ((*q)[0] + z * ((*q)[1] + z * ((*q)[2] + z * ((*q)[3] + z * ((*q)[4] + z * (*q)[5]))))) - ret (0.375 + r / s) / x + r := (*p)[0] + z*((*p)[1]+z*((*p)[2]+z*((*p)[3]+z*((*p)[4]+z*(*p)[5])))) + s := 1 + z*((*q)[0]+z*((*q)[1]+z*((*q)[2]+z*((*q)[3]+z*((*q)[4]+z*(*q)[5]))))) + ret (0.375 + r/s) / x } } \ No newline at end of file diff --git a/std/math/jn.jule b/std/math/jn.jule index dbb50bfd4..cdeda0015 100644 --- a/std/math/jn.jule +++ b/std/math/jn.jule @@ -147,7 +147,7 @@ fn Jn(mut n: int, mut x: f64): f64 { b = J1(x) mut i, mut a := 1, J0(x) for i < n; i++ { - a, b = b, b * (f64(i + i) / x) - a // avoid underflow + a, b = b, b*(f64(i+i)/x) - a // avoid underflow } } } else { @@ -198,22 +198,22 @@ fn Jn(mut n: int, mut x: f64): f64 { // When Q(k) > 1e17 good for quadruple // determine k - w := f64(n + n) / x + w := f64(n+n) / x h := 2 / x mut q0 := w mut z := w + h - mut q1 := w * z - 1 + mut q1 := w*z - 1 mut k := 1 for q1 < 1e9 { k++ z += h - q0, q1 = q1, z * q1 - q0 + q0, q1 = q1, z*q1 - q0 } m := n + n mut t := 0.0 mut i := 2 * (n + k) for i >= m; i -= 2 { - t = 1 / (f64(i) / x - t) + t = 1 / (f64(i)/x - t) } mut a := t b = 1 @@ -227,18 +227,18 @@ fn Jn(mut n: int, mut x: f64): f64 { mut tmp := f64(n) v := 2 / x - tmp = tmp * Log(Abs(v * tmp)) + tmp = tmp * Log(Abs(v*tmp)) if tmp < 7.09782712893383973096e+02 { i = n - 1 for i > 0; i-- { di := f64(i + i) - a, b = b, b * di / x - a + a, b = b, b*di/x - a } } else { i = n - 1 for i > 0; i-- { di := f64(i + i) - a, b = b, b * di / x - a + a, b = b, b*di/x - a // scale b to avoid spurious overflow if b > 1e100 { a /= b @@ -330,7 +330,7 @@ fn Yn(mut n: int, x: f64): f64 { // quit if b is -inf mut i := 1 for i < n && !IsInf(b, -1); i++ { - a, b = b, (f64(i + i) / x) * b - a + a, b = b, (f64(i+i)/x)*b - a } } if sign { diff --git a/std/math/ldexp.jule b/std/math/ldexp.jule index 721d17019..4c0e11020 100644 --- a/std/math/ldexp.jule +++ b/std/math/ldexp.jule @@ -54,7 +54,7 @@ fn Ldexp(mut frac: f64, mut exp: int): f64 { frac, e = normalize(frac) exp += e mut x := F64Bits(frac) - exp += int(x >> shift) & mask - bias + exp += int(x>>shift)&mask - bias if exp < -1075 { ret Copysign(0, frac) // underflow } @@ -70,6 +70,6 @@ fn Ldexp(mut frac: f64, mut exp: int): f64 { m = 1.0 / (1 << 53) // 2**-53 } x = x & ^(mask << shift) - x |= u64(exp + bias) << shift + x |= u64(exp+bias) << shift ret m * F64FromBits(x) } \ No newline at end of file diff --git a/std/math/lgamma.jule b/std/math/lgamma.jule index 4cd357179..54261e89f 100644 --- a/std/math/lgamma.jule +++ b/std/math/lgamma.jule @@ -249,7 +249,7 @@ fn Lgamma(mut x: f64): (lgamma: f64, sign: int) { lgamma = Inf(1) // -integer ret } - nadj = Log(Pi / Abs(t * x)) + nadj = Log(Pi / Abs(t*x)) if t < 0 { sign = -1 } @@ -265,10 +265,10 @@ fn Lgamma(mut x: f64): (lgamma: f64, sign: int) { if x <= 0.9 { lgamma = -Log(x) match { - | x >= (YMIN - 1 + 0.27): // 0.7316 <= x <= 0.9 + | x >= (YMIN-1+0.27): // 0.7316 <= x <= 0.9 y = 1 - x i = 0 - | x >= (YMIN - 1 - 0.27): // 0.2316 <= x < 0.7316 + | x >= (YMIN-1-0.27): // 0.2316 <= x < 0.7316 y = x - (TC - 1) i = 1 |: @@ -279,10 +279,10 @@ fn Lgamma(mut x: f64): (lgamma: f64, sign: int) { } else { lgamma = 0 match { - | x >= (YMIN + 0.27): // 1.7316 <= x < 2 + | x >= (YMIN+0.27): // 1.7316 <= x < 2 y = 2 - x i = 0 - | x >= (YMIN - 0.27): // 1.2316 <= x < 1.7316 + | x >= (YMIN-0.27): // 1.2316 <= x < 1.7316 y = x - TC i = 1 |: @@ -294,29 +294,29 @@ fn Lgamma(mut x: f64): (lgamma: f64, sign: int) { match i { | 0: z := y * y - p1 := _LGAM_A[0] + z * (_LGAM_A[2] + z * (_LGAM_A[4] + z * (_LGAM_A[6] + z * (_LGAM_A[8] + z * _LGAM_A[10])))) - p2 := z * (_LGAM_A[1] + z * (+_LGAM_A[3] + z * (_LGAM_A[5] + z * (_LGAM_A[7] + z * (_LGAM_A[9] + z * _LGAM_A[11]))))) - p := y * p1 + p2 - lgamma += (p - 0.5 * y) + p1 := _LGAM_A[0] + z*(_LGAM_A[2]+z*(_LGAM_A[4]+z*(_LGAM_A[6]+z*(_LGAM_A[8]+z*_LGAM_A[10])))) + p2 := z * (_LGAM_A[1] + z*(+_LGAM_A[3]+z*(_LGAM_A[5]+z*(_LGAM_A[7]+z*(_LGAM_A[9]+z*_LGAM_A[11]))))) + p := y*p1 + p2 + lgamma += (p - 0.5*y) | 1: z := y * y w := z * y - p1 := _LGAM_T[0] + w * (_LGAM_T[3] + w * (_LGAM_T[6] + w * (_LGAM_T[9] + w * _LGAM_T[12]))) // parallel comp - p2 := _LGAM_T[1] + w * (_LGAM_T[4] + w * (_LGAM_T[7] + w * (_LGAM_T[10] + w * _LGAM_T[13]))) - p3 := _LGAM_T[2] + w * (_LGAM_T[5] + w * (_LGAM_T[8] + w * (_LGAM_T[11] + w * _LGAM_T[14]))) - p := z * p1 - (TT - w * (p2 + y * p3)) + p1 := _LGAM_T[0] + w*(_LGAM_T[3]+w*(_LGAM_T[6]+w*(_LGAM_T[9]+w*_LGAM_T[12]))) // parallel comp + p2 := _LGAM_T[1] + w*(_LGAM_T[4]+w*(_LGAM_T[7]+w*(_LGAM_T[10]+w*_LGAM_T[13]))) + p3 := _LGAM_T[2] + w*(_LGAM_T[5]+w*(_LGAM_T[8]+w*(_LGAM_T[11]+w*_LGAM_T[14]))) + p := z*p1 - (TT - w*(p2+y*p3)) lgamma += (TF + p) | 2: - p1 := y * (_LGAM_U[0] + y * (_LGAM_U[1] + y * (_LGAM_U[2] + y * (_LGAM_U[3] + y * (_LGAM_U[4] + y * _LGAM_U[5]))))) - p2 := 1 + y * (_LGAM_V[1] + y * (_LGAM_V[2] + y * (_LGAM_V[3] + y * (_LGAM_V[4] + y * _LGAM_V[5])))) - lgamma += (-0.5 * y + p1 / p2) + p1 := y * (_LGAM_U[0] + y*(_LGAM_U[1]+y*(_LGAM_U[2]+y*(_LGAM_U[3]+y*(_LGAM_U[4]+y*_LGAM_U[5]))))) + p2 := 1 + y*(_LGAM_V[1]+y*(_LGAM_V[2]+y*(_LGAM_V[3]+y*(_LGAM_V[4]+y*_LGAM_V[5])))) + lgamma += (-0.5*y + p1/p2) } | x < 8: // 2 <= x < 8 i := int(x) y := x - f64(i) - p := y * (_LGAM_S[0] + y * (_LGAM_S[1] + y * (_LGAM_S[2] + y * (_LGAM_S[3] + y * (_LGAM_S[4] + y * (_LGAM_S[5] + y * _LGAM_S[6])))))) - q := 1 + y * (_LGAM_R[1] + y * (_LGAM_R[2] + y * (_LGAM_R[3] + y * (_LGAM_R[4] + y * (_LGAM_R[5] + y * _LGAM_R[6]))))) - lgamma = 0.5 * y + p / q + p := y * (_LGAM_S[0] + y*(_LGAM_S[1]+y*(_LGAM_S[2]+y*(_LGAM_S[3]+y*(_LGAM_S[4]+y*(_LGAM_S[5]+y*_LGAM_S[6])))))) + q := 1 + y*(_LGAM_R[1]+y*(_LGAM_R[2]+y*(_LGAM_R[3]+y*(_LGAM_R[4]+y*(_LGAM_R[5]+y*_LGAM_R[6]))))) + lgamma = 0.5*y + p/q mut z := 1.0 // lgamma(1+s) = log(s) + lgamma(s) match i { | 7: @@ -339,8 +339,8 @@ fn Lgamma(mut x: f64): (lgamma: f64, sign: int) { t := Log(x) z := 1 / x y := z * z - w := _LGAM_W[0] + z * (_LGAM_W[1] + y * (_LGAM_W[2] + y * (_LGAM_W[3] + y * (_LGAM_W[4] + y * (_LGAM_W[5] + y * _LGAM_W[6]))))) - lgamma = (x - 0.5) * (t - 1) + w + w := _LGAM_W[0] + z*(_LGAM_W[1]+y*(_LGAM_W[2]+y*(_LGAM_W[3]+y*(_LGAM_W[4]+y*(_LGAM_W[5]+y*_LGAM_W[6]))))) + lgamma = (x-0.5)*(t-1) + w |: // 2**58 <= x <= inf lgamma = x * (Log(x) - 1) diff --git a/std/math/log.jule b/std/math/log.jule index ea4e0314e..291f0775a 100644 --- a/std/math/log.jule +++ b/std/math/log.jule @@ -142,9 +142,9 @@ fn Log(x: f64): f64 { s := f / (2 + f) s2 := s * s s4 := s2 * s2 - t1 := s2 * (L1 + s4 * (L3 + s4 * (L5 + s4 * L7))) - t2 := s4 * (L2 + s4 * (L4 + s4 * L6)) + t1 := s2 * (L1 + s4*(L3+s4*(L5+s4*L7))) + t2 := s4 * (L2 + s4*(L4+s4*L6)) R := t1 + t2 hfsq := 0.5 * f * f - ret k * LN2_HI - ((hfsq - (s * (hfsq + R) + k * LN2_LO)) - f) + ret k*LN2_HI - ((hfsq - (s*(hfsq+R) + k*LN2_LO)) - f) } \ No newline at end of file diff --git a/std/math/log10.jule b/std/math/log10.jule index 96c2fa3ec..f476f9ab1 100644 --- a/std/math/log10.jule +++ b/std/math/log10.jule @@ -48,5 +48,5 @@ fn Log2(x: f64): f64 { if frac == 0.5 { ret f64(exp - 1) } - ret Log(frac) * (1 / Ln2) + f64(exp) + ret Log(frac)*(1/Ln2) + f64(exp) } \ No newline at end of file diff --git a/std/math/log1p.jule b/std/math/log1p.jule index 13f76c35b..cf8764edd 100644 --- a/std/math/log1p.jule +++ b/std/math/log1p.jule @@ -159,7 +159,7 @@ fn Log1p(x: f64): f64 { if absx < Tiny { // |x| < 2**-54 ret x } - ret x - x * x * 0.5 + ret x - x*x*0.5 } if x > Sqrt2Halfm1 { // sqrt(2)/2-1 < x // (sqrt(2)/2-1) < x < (sqrt(2)-1) @@ -209,19 +209,19 @@ fn Log1p(x: f64): f64 { ret 0 } c += f64(k) * Ln2Lo - ret f64(k) * Ln2Hi + c + ret f64(k)*Ln2Hi + c } - R = hfsq * (1.0 - 0.66666666666666666 * f) // avoid division + R = hfsq * (1.0 - 0.66666666666666666*f) // avoid division if k == 0 { ret f - R } - ret f64(k) * Ln2Hi - ((R - (f64(k) * Ln2Lo + c)) - f) + ret f64(k)*Ln2Hi - ((R - (f64(k)*Ln2Lo + c)) - f) } s = f / (2.0 + f) z = s * s - R = z * (LP1 + z * (LP2 + z * (LP3 + z * (LP4 + z * (LP5 + z * (LP6 + z * LP7)))))) + R = z * (LP1 + z*(LP2+z*(LP3+z*(LP4+z*(LP5+z*(LP6+z*LP7)))))) if k == 0 { - ret f - (hfsq - s * (hfsq + R)) + ret f - (hfsq - s*(hfsq+R)) } - ret f64(k) * Ln2Hi - ((hfsq - (s * (hfsq + R) + (f64(k) * Ln2Lo + c))) - f) + ret f64(k)*Ln2Hi - ((hfsq - (s*(hfsq+R) + (f64(k)*Ln2Lo + c))) - f) } \ No newline at end of file diff --git a/std/math/logb.jule b/std/math/logb.jule index e31b4e253..1e4ce0f7d 100644 --- a/std/math/logb.jule +++ b/std/math/logb.jule @@ -76,5 +76,5 @@ fn Ilogb(x: f64): int { // Returns the binary exponent of x. It assumes x is finite and non-zero. fn ilogb(mut x: f64): int { x, exp := normalize(x) - ret int((F64Bits(x) >> shift) & mask) - bias + exp + ret int((F64Bits(x)>>shift)&mask) - bias + exp } \ No newline at end of file diff --git a/std/math/mod.jule b/std/math/mod.jule index 9ec611ddf..b2e395a97 100644 --- a/std/math/mod.jule +++ b/std/math/mod.jule @@ -66,7 +66,7 @@ fn Mod(x: f64, mut y: f64): f64 { if rfr < yfr { rexp = rexp - 1 } - r = r - Ldexp(y, rexp - yexp) + r = r - Ldexp(y, rexp-yexp) } if x < 0 { r = -r diff --git a/std/math/pow.jule b/std/math/pow.jule index 97e01ce61..5ff31e6f2 100644 --- a/std/math/pow.jule +++ b/std/math/pow.jule @@ -93,7 +93,7 @@ fn Pow(x: f64, y: f64): f64 { } | IsInf(x, 0): if IsInf(x, -1) { - ret Pow(1 / x, -y) // Pow(-0, -y) + ret Pow(1/x, -y) // Pow(-0, -y) } match { | y < 0: diff --git a/std/math/rand/rand.jule b/std/math/rand/rand.jule index 2031a48c0..0d5d6ef9d 100644 --- a/std/math/rand/rand.jule +++ b/std/math/rand/rand.jule @@ -30,7 +30,7 @@ struct Rand { } impl Rand { - const seedMask = 1 << 63 - 1 + const seedMask = 1<<63 - 1 // Returns new PRNG for seed. static fn New(seed: Seed): &Rand { @@ -50,7 +50,7 @@ impl Rand { // Processes, sets, and returns new seed. fn snext(self): Seed { const NextMask = 0x41C64E6D - self.setSeed((self.seed * NextMask + 0x3039) & Rand.seedMask) + self.setSeed((self.seed*NextMask + 0x3039) & Rand.seedMask) ret self.seed } @@ -81,10 +81,10 @@ impl Rand { if n <= 0 { panic("Rand.Nextn63: invalid argument") } - if n&(n - 1) == 0 { + if n&(n-1) == 0 { ret self.Next63() & (n - 1) } - max := i64(1 << 63 - 1 - (1 << 63) % u64(n)) + max := i64(1<<63 - 1 - (1<<63)%u64(n)) mut v := self.Next63() for v > max { v = self.Next63() @@ -99,10 +99,10 @@ impl Rand { if n <= 0 { panic("Rand.nextn31: invalid argument") } - if n&(n - 1) == 0 { + if n&(n-1) == 0 { ret self.Next31() & (n - 1) } - max := i32(1 << 31 - 1 - (1 << 31) % u32(n)) + max := i32(1<<31 - 1 - (1<<31)%u32(n)) mut v := self.Next31() for v > max { v = self.Next31() diff --git a/std/math/remainder.jule b/std/math/remainder.jule index fd6e88dac..2951275d4 100644 --- a/std/math/remainder.jule +++ b/std/math/remainder.jule @@ -92,7 +92,7 @@ fn Remainder(mut x: f64, mut y: f64): f64 { ret 0 } if y <= HalfMax { - x = Mod(x, y + y) // now x < 2y + x = Mod(x, y+y) // now x < 2y } if y < Tiny { if x+x > y { diff --git a/std/math/signbit.jule b/std/math/signbit.jule index eee3e89df..a88025bfe 100644 --- a/std/math/signbit.jule +++ b/std/math/signbit.jule @@ -36,4 +36,4 @@ // ==================================================== // Reports whether x is negative or negative zero. -fn Signbit(x: f64): bool { ret F64Bits(x)&(1 << 63) != 0 } \ No newline at end of file +fn Signbit(x: f64): bool { ret F64Bits(x)&(1<<63) != 0 } \ No newline at end of file diff --git a/std/math/sin.jule b/std/math/sin.jule index 499409678..3f31161fb 100644 --- a/std/math/sin.jule +++ b/std/math/sin.jule @@ -173,7 +173,7 @@ fn Cos(mut x: f64): f64 { y++ } j &= 7 // octant modulo 2Pi radians (360 degrees) - z = ((x - y * PI4A) - y * PI4B) - y * PI4C // Extended precision modular arithmetic + z = ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic } if j > 3 { @@ -186,9 +186,9 @@ fn Cos(mut x: f64): f64 { zz := z * z if j == 1 || j == 2 { - y = z + z * zz * ((((((_SIN[0] * zz) + _SIN[1]) * zz + _SIN[2]) * zz + _SIN[3]) * zz + _SIN[4]) * zz + _SIN[5]) + y = z + z*zz*((((((_SIN[0]*zz)+_SIN[1])*zz+_SIN[2])*zz+_SIN[3])*zz+_SIN[4])*zz+_SIN[5]) } else { - y = 1.0 - 0.5 * zz + zz * zz * ((((((_COS[0] * zz) + _COS[1]) * zz + _COS[2]) * zz + _COS[3]) * zz + _COS[4]) * zz + _COS[5]) + y = 1.0 - 0.5*zz + zz*zz*((((((_COS[0]*zz)+_COS[1])*zz+_COS[2])*zz+_COS[3])*zz+_COS[4])*zz+_COS[5]) } if sign { y = -y @@ -236,7 +236,7 @@ fn Sin(mut x: f64): f64 { y++ } j &= 7 // octant modulo 2Pi radians (360 degrees) - z = ((x - y * PI4A) - y * PI4B) - y * PI4C // Extended precision modular arithmetic + z = ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic } // reflect in x axis if j > 3 { @@ -245,9 +245,9 @@ fn Sin(mut x: f64): f64 { } zz := z * z if j == 1 || j == 2 { - y = 1.0 - 0.5 * zz + zz * zz * ((((((_COS[0] * zz) + _COS[1]) * zz + _COS[2]) * zz + _COS[3]) * zz + _COS[4]) * zz + _COS[5]) + y = 1.0 - 0.5*zz + zz*zz*((((((_COS[0]*zz)+_COS[1])*zz+_COS[2])*zz+_COS[3])*zz+_COS[4])*zz+_COS[5]) } else { - y = z + z * zz * ((((((_SIN[0] * zz) + _SIN[1]) * zz + _SIN[2]) * zz + _SIN[3]) * zz + _SIN[4]) * zz + _SIN[5]) + y = z + z*zz*((((((_SIN[0]*zz)+_SIN[1])*zz+_SIN[2])*zz+_SIN[3])*zz+_SIN[4])*zz+_SIN[5]) } if sign { y = -y diff --git a/std/math/sincos.jule b/std/math/sincos.jule index d5f0409ce..7df181a64 100644 --- a/std/math/sincos.jule +++ b/std/math/sincos.jule @@ -76,7 +76,7 @@ fn Sincos(mut x: f64): (sin: f64, cos: f64) { y++ } j &= 7 // octant modulo 2Pi radians (360 degrees) - z = ((x - y * PI4A) - y * PI4B) - y * PI4C // Extended precision modular arithmetic + z = ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic } if j > 3 { // reflect in x axis j -= 4 @@ -87,8 +87,8 @@ fn Sincos(mut x: f64): (sin: f64, cos: f64) { } zz := z * z - cos = 1.0 - 0.5 * zz + zz * zz * ((((((_COS[0] * zz) + _COS[1]) * zz + _COS[2]) * zz + _COS[3]) * zz + _COS[4]) * zz + _COS[5]) - sin = z + z * zz * ((((((_SIN[0] * zz) + _SIN[1]) * zz + _SIN[2]) * zz + _SIN[3]) * zz + _SIN[4]) * zz + _SIN[5]) + cos = 1.0 - 0.5*zz + zz*zz*((((((_COS[0]*zz)+_COS[1])*zz+_COS[2])*zz+_COS[3])*zz+_COS[4])*zz+_COS[5]) + sin = z + z*zz*((((((_SIN[0]*zz)+_SIN[1])*zz+_SIN[2])*zz+_SIN[3])*zz+_SIN[4])*zz+_SIN[5]) if j == 1 || j == 2 { sin, cos = cos, sin } diff --git a/std/math/sinh.jule b/std/math/sinh.jule index 6ce6053df..318757ce7 100644 --- a/std/math/sinh.jule +++ b/std/math/sinh.jule @@ -75,11 +75,11 @@ fn Sinh(mut x: f64): f64 { temp = Exp(x) * 0.5 | x > 0.5: ex := Exp(x) - temp = (ex - 1 / ex) * 0.5 + temp = (ex - 1/ex) * 0.5 |: sq := x * x - temp = (((P3 * sq + P2) * sq + P1) * sq + P0) * x - temp = temp / (((sq + Q2) * sq + Q1) * sq + Q0) + temp = (((P3*sq+P2)*sq+P1)*sq + P0) * x + temp = temp / (((sq+Q2)*sq+Q1)*sq + Q0) } if sign { @@ -100,5 +100,5 @@ fn Cosh(mut x: f64): f64 { ret Exp(x) * 0.5 } ex := Exp(x) - ret (ex + 1 / ex) * 0.5 + ret (ex + 1/ex) * 0.5 } \ No newline at end of file diff --git a/std/math/sqrt.jule b/std/math/sqrt.jule index 18ec09635..8295048a1 100644 --- a/std/math/sqrt.jule +++ b/std/math/sqrt.jule @@ -132,7 +132,7 @@ fn Sqrt(x: f64): f64 { // normalize x mut exp := int((ix >> shift) & mask) if exp == 0 { // subnormal x - for ix&(1 << shift) == 0 { + for ix&(1<> 1 + u64(exp - 1 + bias) << shift // significand + biased exponent + ix = q>>1 + u64(exp-1+bias)< 1e-14 { - y = z + z * (zz * (((_TAN_P[0] * zz) + _TAN_P[1]) * zz + _TAN_P[2]) / ((((zz + _TAN_Q[1]) * zz + _TAN_Q[2]) * zz + _TAN_Q[3]) * zz + _TAN_Q[4])) + y = z + z*(zz*(((_TAN_P[0]*zz)+_TAN_P[1])*zz+_TAN_P[2])/((((zz+_TAN_Q[1])*zz+_TAN_Q[2])*zz+_TAN_Q[3])*zz+_TAN_Q[4])) } else { y = z } diff --git a/std/math/tanh.jule b/std/math/tanh.jule index b5455b02d..7a503ea19 100644 --- a/std/math/tanh.jule +++ b/std/math/tanh.jule @@ -114,7 +114,7 @@ fn Tanh(x: f64): f64 { ret 1 | z >= 0.625: s := Exp(2 * z) - z = 1 - 2 / (s + 1) + z = 1 - 2/(s+1) if x < 0 { z = -z } @@ -123,7 +123,7 @@ fn Tanh(x: f64): f64 { ret x } s := x * x - z = x + x * s * ((tanhp[0] * s + tanhp[1]) * s + tanhp[2]) / (((s + tanhq[0]) * s + tanhq[1]) * s + tanhq[2]) + z = x + x*s*((tanhp[0]*s+tanhp[1])*s+tanhp[2])/(((s+tanhq[0])*s+tanhq[1])*s+tanhq[2]) } ret z } \ No newline at end of file diff --git a/std/math/trig_reduce.jule b/std/math/trig_reduce.jule index f26be10a1..71c7c9fbb 100644 --- a/std/math/trig_reduce.jule +++ b/std/math/trig_reduce.jule @@ -65,13 +65,13 @@ fn trigReduce(mut x: f64): (j: u64, z: f64) { // Extract out the integer and exponent such that, // x = ix * 2 ** exp. mut ix := F64Bits(x) - exp := int(ix >> shift & mask) - bias - shift + exp := int(ix>>shift&mask) - bias - shift ix = ix & ^(mask << shift) ix |= 1 << shift // Use the exponent to extract the 3 appropriate uint64 digits from M_PI4, // B ~ (z0, z1, z2), such that the product leading digit has the exponent -61. // Note, exp >= -53 since x >= PI4 and exp < 971 for maximum f64. - digit, bitshift := uint(exp + 61) / 64, uint(exp + 61) % 64 + digit, bitshift := uint(exp+61) / 64, uint(exp+61) % 64 z0 := (M_PI4[digit] << bitshift) | (M_PI4[digit+1] >> (64 - bitshift)) z1 := (M_PI4[digit+1] << bitshift) | (M_PI4[digit+2] >> (64 - bitshift)) z2 := (M_PI4[digit+2] << bitshift) | (M_PI4[digit+3] >> (64 - bitshift)) @@ -84,7 +84,7 @@ fn trigReduce(mut x: f64): (j: u64, z: f64) { // The top 3 bits are j. j = hi >> 61 // Extract the fraction and find its magnitude. - hi = hi << 3 | lo >> 61 + hi = hi<<3 | lo>>61 lz := uint(bits::LeadingZeros64(hi)) e := u64(bias - (lz + 1)) // Clear implicit mantissa bit and shift into place. diff --git a/std/net/ip.jule b/std/net/ip.jule index 5df4819ba..504808cad 100644 --- a/std/net/ip.jule +++ b/std/net/ip.jule @@ -142,7 +142,7 @@ impl Ip { static v4InV6Prefix: []byte = [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF] // IPv4 functionalities. -struct Ipv4 {} +struct Ipv4{} impl Ipv4 { // Length of IPv4 address in bytes. @@ -190,7 +190,7 @@ impl Ipv4 { } // IPv6 functionalities. -struct Ipv6 {} +struct Ipv6{} impl Ipv6 { // Length of IPv6 address in bytes. @@ -250,7 +250,7 @@ fn isZeros(addr: []byte): bool { } fn hexStr(b: []byte): str { - mut s := make([]byte, (len(b) << 1) + 1) + mut s := make([]byte, (len(b)<<1)+1) for i, tn in b { s[i<<1], s[i<<1+1] = hexDigit[tn>>4], hexDigit[tn&0xF] } diff --git a/std/net/ip_addr.jule b/std/net/ip_addr.jule index 544a3e3d2..e8ddc63ee 100644 --- a/std/net/ip_addr.jule +++ b/std/net/ip_addr.jule @@ -10,7 +10,7 @@ use fastbytes for std::internal::fastbytes fn ipAddrFrom4(addr: []byte): u128 { ret u128{ hi: 0, - lo: 0xFFFF00000000 | u64(addr[0]) << 24 | u64(addr[1]) << 16 | u64(addr[2]) << 8 | u64(addr[3]), + lo: 0xFFFF00000000 | u64(addr[0])<<24 | u64(addr[1])<<16 | u64(addr[2])<<8 | u64(addr[3]), } } @@ -23,12 +23,12 @@ fn ipAddrFrom16(addr: []byte): u128 { } fn beU64(b: []byte): u64 { - ret u64(b[7]) | u64(b[6]) << 8 | u64(b[5]) << 16 | u64(b[4]) << 24 | - u64(b[3]) << 32 | u64(b[2]) << 40 | u64(b[1]) << 48 | u64(b[0]) << 56 + ret u64(b[7]) | u64(b[6])<<8 | u64(b[5])<<16 | u64(b[4])<<24 | + u64(b[3])<<32 | u64(b[2])<<40 | u64(b[1])<<48 | u64(b[0])<<56 } fn beU64v4(b: []byte): u64 { - ret u64(b[3]) << 24 | u64(b[2]) << 16 | u64(b[1]) << 8 | u64(b[0]) + ret u64(b[3])<<24 | u64(b[2])<<16 | u64(b[1])<<8 | u64(b[0]) } fn bePutU64v4(mut b: []byte, v: u64) { @@ -64,7 +64,7 @@ fn v6u16(ip: u128, i: byte): u16 { } else { p = ip.lo } - ret u16(p >> ((3 - i % 4) << 4)) + ret u16(p >> ((3 - i%4) << 4)) } // String of the hex digits from 0 to f. It's used in @@ -151,7 +151,7 @@ fn parseIPv4Fields(&addr: str, off: int, end: int, mut fields: []byte)! { if digLen == 1 && val == 0 { error(AddrError.IPv4FieldOctetWithLeadingZero) } - val = val * 10 + int(s[i]) - '0' + val = val*10 + int(s[i]) - '0' digLen++ if val > 255 { error(AddrError.IPv4FieldValueOverflow) @@ -232,11 +232,11 @@ fn parseIPv6(&addr: str)!: TcpAddr { for off < len(s); off++ { c := s[off] if c >= '0' && c <= '9' { - acc = (acc << 4) + u32(c - '0') + acc = (acc << 4) + u32(c-'0') } else if c >= 'a' && c <= 'f' { - acc = (acc << 4) + u32(c - 'a' + 10) + acc = (acc << 4) + u32(c-'a'+10) } else if c >= 'A' && c <= 'F' { - acc = (acc << 4) + u32(c - 'A' + 10) + acc = (acc << 4) + u32(c-'A'+10) } else { break } @@ -269,7 +269,7 @@ fn parseIPv6(&addr: str)!: TcpAddr { if len(zone) > 0 { end -= len(zone) + 1 } - parseIPv4Fields(addr, end - len(s), end, ip[i:i+4]) else { error(error) } + parseIPv4Fields(addr, end-len(s), end, ip[i:i+4]) else { error(error) } s = s[:0] i += 4 break diff --git a/std/net/mac.jule b/std/net/mac.jule index 0571fa504..252916beb 100644 --- a/std/net/mac.jule +++ b/std/net/mac.jule @@ -32,7 +32,7 @@ impl HardwareAddr { } mut addrB := unsafe::StrBytes(addr) if addr[2] == ':' || addr[2] == '-' { - if (len(addr) + 1)%3 != 0 { + if (len(addr)+1)%3 != 0 { error(AddrError.Unable) } n := (len(addr) + 1) / 3 @@ -53,7 +53,7 @@ impl HardwareAddr { Addr: hAddr, } } else if addr[4] == '.' { - if (len(addr) + 1)%5 != 0 { + if (len(addr)+1)%5 != 0 { error(AddrError.Unable) } n := ((len(addr) + 1) << 1) / 5 @@ -86,7 +86,7 @@ impl HardwareAddr { if len(self.Addr) == 0 { ret "" } - mut buf := StrBuilder.New(len(self.Addr) * 3 - 1) + mut buf := StrBuilder.New(len(self.Addr)*3 - 1) for i, b in self.Addr { if i > 0 { buf.WriteByte(':') diff --git a/std/net/sock_unix.jule b/std/net/sock_unix.jule index 24699483a..296258ebd 100644 --- a/std/net/sock_unix.jule +++ b/std/net/sock_unix.jule @@ -66,7 +66,7 @@ unsafe fn connectSocket(handle: netHandle, sockAddr: *sys::Sockaddr, sockLen: ui sys::FdSet(handle, &fd) lookup: for { - res = sys::Select(handle + 1, nil, &fd, nil, &tv) + res = sys::Select(handle+1, nil, &fd, nil, &tv) err := lastErrorCode() match { | res < 0 && err != sys::EINTR: diff --git a/std/net/sock_windows.jule b/std/net/sock_windows.jule index d8602dabc..86747823d 100644 --- a/std/net/sock_windows.jule +++ b/std/net/sock_windows.jule @@ -20,7 +20,7 @@ fn closeSocket(handle: netHandle): bool { } fn setSocketBlockingMode(handle: netHandle, mode: UnsignedLong)! { - FIONBIO := 0x80000000 | (Long(mem::SizeOf(UnsignedLong) & 0x7F) << 16) | ('f' << 8) | 126 + FIONBIO := 0x80000000 | (Long(mem::SizeOf(UnsignedLong)&0x7F) << 16) | ('f' << 8) | 126 unsafe { if sys::Ioctlsocket(handle, FIONBIO, &mode) == sys::SOCKET_ERROR { error(lastErrorCode()) diff --git a/std/net/tcp.jule b/std/net/tcp.jule index 5ce0a058f..4285b800e 100644 --- a/std/net/tcp.jule +++ b/std/net/tcp.jule @@ -21,7 +21,7 @@ impl Addr for TcpAddr { fn Str(self): str { ip := self.Ip.ipEmptyStr() if self.Zone != "" { - ret JoinHostPort(ip + "%" + self.Zone, conv::Itoa(self.Port)) + ret JoinHostPort(ip+"%"+self.Zone, conv::Itoa(self.Port)) } ret JoinHostPort(ip, conv::Itoa(self.Port)) } diff --git a/std/net/udp.jule b/std/net/udp.jule index afab0c292..ed4d7003b 100644 --- a/std/net/udp.jule +++ b/std/net/udp.jule @@ -21,7 +21,7 @@ impl Addr for UdpAddr { fn Str(self): str { ip := self.Ip.ipEmptyStr() if self.Zone != "" { - ret JoinHostPort(ip + "%" + self.Zone, conv::Itoa(self.Port)) + ret JoinHostPort(ip+"%"+self.Zone, conv::Itoa(self.Port)) } ret JoinHostPort(ip, conv::Itoa(self.Port)) } diff --git a/std/process/cmd_unix.jule b/std/process/cmd_unix.jule index 9622e8e48..1af1097b0 100644 --- a/std/process/cmd_unix.jule +++ b/std/process/cmd_unix.jule @@ -33,7 +33,7 @@ struct cmdAttrs { } fn strSliceToCstrSlice(&s: []str, mut &bargs: [][]byte): []*integ::Char { - mut cs := make([]*integ::Char, len(s) + 1) + mut cs := make([]*integ::Char, len(s)+1) bargs = make([][]byte, len(s)) for i, arg in s { mut barg := integ::StrToBytes(arg) @@ -98,7 +98,7 @@ impl Cmd { error(ProcessError.Spawn) | 0: sys::Close(int(pipe[0])) - mut args := make([]str, 1, 1 + len(self.Args)) + mut args := make([]str, 1, 1+len(self.Args)) args[0] = path args = append(args, self.Args...) setenv(self.Env) else { error(error) } diff --git a/std/process/cmd_windows.jule b/std/process/cmd_windows.jule index e120e692e..ed9bc079e 100644 --- a/std/process/cmd_windows.jule +++ b/std/process/cmd_windows.jule @@ -49,7 +49,7 @@ impl Cmd { cpp.ZeroMemory(&processInfo, mem::SizeOf(processInfo)) } startupInfo.cb = mem::SizeOf(startupInfo) - mut args := make([]str, 1, 1 + len(self.Args)) + mut args := make([]str, 1, 1+len(self.Args)) args[0] = self.path args = append(args, self.Args...) argv := integ::UTF16FromStr(makeCmdLine(args)) diff --git a/std/runtime/conv.jule b/std/runtime/conv.jule index f7895a8c9..ff9f04d93 100644 --- a/std/runtime/conv.jule +++ b/std/runtime/conv.jule @@ -64,7 +64,7 @@ fn u64ToBuf(mut buf: []byte, mut x: u64): int { mut i := 0 for x >= 10 { q := x / 10 - buf[i] = byte('0' + x - q * 10) + buf[i] = byte('0' + x - q*10) i++ x = q } diff --git a/std/runtime/env_darwin.jule b/std/runtime/env_darwin.jule index 37c6a835e..39fceb1f9 100644 --- a/std/runtime/env_darwin.jule +++ b/std/runtime/env_darwin.jule @@ -4,7 +4,6 @@ use sys for std::sys use integ for std::jule::integrated - cpp use "" cpp unsafe fn _NSGetExecutablePath(b: *integ::Char, *u32): bool diff --git a/std/runtime/env_linux.jule b/std/runtime/env_linux.jule index c94669182..407a80994 100644 --- a/std/runtime/env_linux.jule +++ b/std/runtime/env_linux.jule @@ -5,7 +5,6 @@ use std::unsafe use sys for std::sys use integ for std::jule::integrated - cpp use "" cpp unsafe fn readlink(*integ::Char, *integ::Char, int): int diff --git a/std/runtime/env_unix.jule b/std/runtime/env_unix.jule index bc55d6caa..75a9b0dd8 100644 --- a/std/runtime/env_unix.jule +++ b/std/runtime/env_unix.jule @@ -29,6 +29,8 @@ fn env(): []str { } unsafe fn strlen(mut p: *byte): (n: int) { - for *p != 0; p++ { n++ } + for *p != 0; p++ { + n++ + } ret } \ No newline at end of file diff --git a/std/runtime/env_windows.jule b/std/runtime/env_windows.jule index 5402af3b3..b647d72d8 100644 --- a/std/runtime/env_windows.jule +++ b/std/runtime/env_windows.jule @@ -32,7 +32,8 @@ fn env(): []str { mut latest := envS unsafe { for *latest != NULL { - for *np != NULL; np++ {} + for *np != NULL; np++ { + } env = append(env, integ::U16PtrToStr((*u16)(latest))) np++ latest = np diff --git a/std/runtime/map.jule b/std/runtime/map.jule index bca4164f0..52b647a59 100644 --- a/std/runtime/map.jule +++ b/std/runtime/map.jule @@ -179,7 +179,7 @@ impl _Map { ret mapInitialSize } n = len(self.groups) << 2 - if self.dead >= (self.resident >> 1) { + if self.dead >= (self.resident>>1) { n = len(self.groups) } ret diff --git a/std/runtime/maphash.jule b/std/runtime/maphash.jule index fa4c93a0e..1caa9f421 100644 --- a/std/runtime/maphash.jule +++ b/std/runtime/maphash.jule @@ -74,18 +74,18 @@ fn hashLen16_3(u: u64, v: u64, mul: u64): u64 { fn hashLen0to16(bytes: []byte, n: int): u64 { if n >= 8 { - mul := k2 + u64(n) << 1 + mul := k2 + u64(n)<<1 a := fetch64(bytes) + k2 b := fetch64(bytes[n-8:]) - c := rotate64(b, 37) * mul + a + c := rotate64(b, 37)*mul + a d := (rotate64(a, 25) + b) * mul ret hashLen16_3(c, d, mul) } if n >= 4 { - mul := k2 + u64(n) << 1 + mul := k2 + u64(n)<<1 a := u64(fetch32(bytes)) - ret hashLen16_3(u64(n) + (a << 3), u64(fetch32(bytes[n-4:])), mul) + ret hashLen16_3(u64(n)+(a<<3), u64(fetch32(bytes[n-4:])), mul) } if n > 0 { @@ -94,7 +94,7 @@ fn hashLen0to16(bytes: []byte, n: int): u64 { c := u8(bytes[n-1]) y := u32(a) + (u32(b) << 8) z := n + (int(c) << 2) - ret shiftMix(u64(y) * k2 ^ u64(z) * k0) * k2 + ret shiftMix(u64(y)*k2^u64(z)*k0) * k2 } ret k2 @@ -108,8 +108,8 @@ fn hashMurmur(mut bytes: []byte, n: int, seed: u128): u128 { mut l := n - 16 if l <= 0 { // len <= 16 - a = shiftMix(a * k1) * k1 - c = b * k1 + hashLen0to16(bytes, n) + a = shiftMix(a*k1) * k1 + c = b*k1 + hashLen0to16(bytes, n) if n >= 8 { d = shiftMix(a + fetch64(bytes)) @@ -117,15 +117,15 @@ fn hashMurmur(mut bytes: []byte, n: int, seed: u128): u128 { d = shiftMix(a + c) } } else { // len > 16 - c = hashLen16(fetch64(bytes[n-8:]) + k1, a) - d = hashLen16(b + u64(n), c + fetch64(bytes[n-16:])) + c = hashLen16(fetch64(bytes[n-8:])+k1, a) + d = hashLen16(b+u64(n), c+fetch64(bytes[n-16:])) a += d for { - a ^= shiftMix(fetch64(bytes) * k1) * k1 + a ^= shiftMix(fetch64(bytes)*k1) * k1 a *= k1 b ^= a - c ^= shiftMix(fetch64(bytes[8:]) * k1) * k1 + c ^= shiftMix(fetch64(bytes[8:])*k1) * k1 c *= k1 d ^= c bytes = bytes[16:] @@ -144,7 +144,7 @@ fn hashMurmur(mut bytes: []byte, n: int, seed: u128): u128 { fn weakHashLen32WithSeeds(w: u64, x: u64, y: u64, z: u64, mut a: u64, mut b: u64): u128 { a += w - b = rotate64(b + a + z, 21) + b = rotate64(b+a+z, 21) c := a a += x a += y @@ -172,29 +172,29 @@ fn hashWithSeed(mut bytes: []byte, mut n: int, seed: u128): u128 { mut y := seed.hi mut z := u64(n) * k1 - v.lo = rotate64(y ^ k1, 49) * k1 + fetch64(bytes) - v.hi = rotate64(v.lo, 42) * k1 + fetch64(bytes[8:]) - w.lo = rotate64(y + z, 35) * k1 + x - w.hi = rotate64(x + fetch64(bytes[88:]), 53) * k1 + v.lo = rotate64(y^k1, 49)*k1 + fetch64(bytes) + v.hi = rotate64(v.lo, 42)*k1 + fetch64(bytes[8:]) + w.lo = rotate64(y+z, 35)*k1 + x + w.hi = rotate64(x+fetch64(bytes[88:]), 53) * k1 // This is the same inner loop as CityHash64(), manually unrolled. for { - x = rotate64(x + y + v.lo + fetch64(bytes[8:]), 37) * k1 - y = rotate64(y + v.hi + fetch64(bytes[48:]), 42) * k1 + x = rotate64(x+y+v.lo+fetch64(bytes[8:]), 37) * k1 + y = rotate64(y+v.hi+fetch64(bytes[48:]), 42) * k1 x ^= w.hi y += v.lo + fetch64(bytes[40:]) - z = rotate64(z + w.lo, 33) * k1 - v = weakHashLen32WithSeeds_3(bytes, v.hi * k1, x + w.lo) - w = weakHashLen32WithSeeds_3(bytes[32:], z + w.hi, y + fetch64(bytes[16:])) + z = rotate64(z+w.lo, 33) * k1 + v = weakHashLen32WithSeeds_3(bytes, v.hi*k1, x+w.lo) + w = weakHashLen32WithSeeds_3(bytes[32:], z+w.hi, y+fetch64(bytes[16:])) z, x = x, z bytes = bytes[64:] - x = rotate64(x + y + v.lo + fetch64(bytes[8:]), 37) * k1 - y = rotate64(y + v.hi + fetch64(bytes[48:]), 42) * k1 + x = rotate64(x+y+v.lo+fetch64(bytes[8:]), 37) * k1 + y = rotate64(y+v.hi+fetch64(bytes[48:]), 42) * k1 x ^= w.hi y += v.lo + fetch64(bytes[40:]) - z = rotate64(z + w.lo, 33) * k1 - v = weakHashLen32WithSeeds_3(bytes, v.hi * k1, x + w.lo) - w = weakHashLen32WithSeeds_3(bytes[32:], z + w.hi, y + fetch64(bytes[16:])) + z = rotate64(z+w.lo, 33) * k1 + v = weakHashLen32WithSeeds_3(bytes, v.hi*k1, x+w.lo) + w = weakHashLen32WithSeeds_3(bytes[32:], z+w.hi, y+fetch64(bytes[16:])) z, x = x, z bytes = bytes[64:] n -= 128 @@ -203,9 +203,9 @@ fn hashWithSeed(mut bytes: []byte, mut n: int, seed: u128): u128 { } } - x += rotate64(v.lo + z, 49) * k0 - y = y * k0 + rotate64(w.hi, 37) - z = z * k0 + rotate64(w.lo, 27) + x += rotate64(v.lo+z, 49) * k0 + y = y*k0 + rotate64(w.hi, 37) + z = z*k0 + rotate64(w.lo, 27) w.lo *= 9 v.lo *= k0 @@ -213,12 +213,12 @@ fn hashWithSeed(mut bytes: []byte, mut n: int, seed: u128): u128 { let mut tailDone = 0 for tailDone < n { tailDone += 32 - y = rotate64(x + y, 42) * k0 + v.hi + y = rotate64(x+y, 42)*k0 + v.hi w.lo += fetch64(t[rn-tailDone+16:]) - x = x * k0 + w.lo + x = x*k0 + w.lo z += w.hi + fetch64(t[rn-tailDone:]) w.hi += v.lo - v = weakHashLen32WithSeeds_3(t[rn-tailDone:], v.lo + z, v.hi) + v = weakHashLen32WithSeeds_3(t[rn-tailDone:], v.lo+z, v.hi) v.lo *= k0 } @@ -226,16 +226,16 @@ fn hashWithSeed(mut bytes: []byte, mut n: int, seed: u128): u128 { // enough information for a strong 128-bit hash. We use two // different 56-byte-to-8-byte hashes to get a 16-byte final result. x = hashLen16(x, v.lo) - y = hashLen16(y + z, w.lo) + y = hashLen16(y+z, w.lo) - ret u128{hashLen16(x + v.hi, w.hi) + y, hashLen16(x + w.hi, y + v.hi)} + ret u128{hashLen16(x+v.hi, w.hi) + y, hashLen16(x+w.hi, y+v.hi)} } fn hash(mut bytes: []byte): u64 { mut sum := u128{} if len(bytes) > 16 { - sum = hashWithSeed(bytes[16:], len(bytes) - 16, - u128{fetch64(bytes), fetch64(bytes[8:]) + k0}) + sum = hashWithSeed(bytes[16:], len(bytes)-16, + u128{fetch64(bytes), fetch64(bytes[8:])+k0}) } else { sum = hashWithSeed(bytes, len(bytes), u128{k0, k1}) } diff --git a/std/runtime/rand.jule b/std/runtime/rand.jule index bfec0de5f..e827e71b0 100644 --- a/std/runtime/rand.jule +++ b/std/runtime/rand.jule @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD 3-Clause // license that can be found in the LICENSE file. -const seedMask = 1 << 63 - 1 +const seedMask = 1<<63 - 1 fn randInt(mut seed: u64, max: int): int { const nextMask = 0x41C64E6D const magic = 0x3039 - const rngMask = 1 << 63 - 1 + const rngMask = 1<<63 - 1 seed = seed & seedMask seed += seed * (seed >> (1 << 3)) - seed = seed * nextMask + magic + seed = seed*nextMask + magic seed = seed & seedMask seed += seed * (seed >> (1 << 3)) p1 := i64(seed & rngMask) p2 := uint(p1) - ret int(p2 << 1 >> 1) % max + ret int(p2<<1>>1) % max } \ No newline at end of file diff --git a/std/runtime/strings.jule b/std/runtime/strings.jule index fd824fae7..5bdf1ac59 100644 --- a/std/runtime/strings.jule +++ b/std/runtime/strings.jule @@ -42,7 +42,7 @@ fn bytesToStr(bytes: []byte): str { // Converts []rune to str. #export "__jule_runesToStr" fn runesToStr(runes: []rune): str { - mut buf := make([]byte, 0, len(runes) * utf8::UTFMax) + mut buf := make([]byte, 0, len(runes)*utf8::UTFMax) for _, r in runes { buf = utf8::AppendRune(buf, r) } diff --git a/std/runtime/thread_unix.jule b/std/runtime/thread_unix.jule index 4e915ff6d..4110ecb9d 100644 --- a/std/runtime/thread_unix.jule +++ b/std/runtime/thread_unix.jule @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. use integ for std::jule::integrated - cpp use "" cpp unsafe fn pthread_create(*cpp.pthread_t, *unsafe, *unsafe, *unsafe): int diff --git a/std/slices/sortfunc.jule b/std/slices/sortfunc.jule index b351a0cab..90e444e72 100644 --- a/std/slices/sortfunc.jule +++ b/std/slices/sortfunc.jule @@ -51,7 +51,7 @@ fn insertionSortFunc[S: []E, E](mut data: S, a: int, b: int, cmp: fn(a: E, b: E) fn siftDownFunc[S: []E, E](mut data: S, lo: int, hi: int, first: int, cmp: fn(a: E, b: E): int) { mut root := lo for { - mut child := 2 * root + 1 + mut child := 2*root + 1 if child >= hi { break } @@ -93,8 +93,8 @@ fn breakPatternsFunc[S: []E, E](mut data: S, a: int, b: int, cmp: fn(a: E, b: E) mut random := xorshift(length) modulus := nextPowerOfTwo(length) - mut idx := a + (length >> 2) << 1 - 1 - for idx <= a+(length >> 2)<<1+1; idx++ { + mut idx := a + (length>>2)<<1 - 1 + for idx <= a+(length>>2)<<1+1; idx++ { mut other := int(uint(xorshiftNext(random)) & (modulus - 1)) if other >= length { other -= length @@ -123,7 +123,7 @@ fn medianFunc[S: []E, E](data: S, mut a: int, mut b: int, mut c: int, mut &swaps // Finds the median of data[a - 1], data[a], data[a + 1] and stores the index into a. fn medianAdjacentFunc[S: []E, E](mut data: S, a: int, mut &swaps: int, cmp: fn(a: E, b: E): int): int { - ret medianFunc(data, a - 1, a, a + 1, swaps, cmp) + ret medianFunc(data, a-1, a, a+1, swaps, cmp) } // Chooses a pivot in data[a:b]. @@ -138,9 +138,9 @@ fn choosePivotFunc[S: []E, E](mut data: S, a: int, b: int, cmp: fn(a: E, b: E): l := b - a mut swaps := 0 - mut i := a + l >> 2 * 1 - mut j := a + l >> 2 * 2 - mut k := a + l >> 2 * 3 + mut i := a + l>>2*1 + mut j := a + l>>2*2 + mut k := a + l>>2*3 if l >= 8 { if l >= shortestNinther { @@ -350,7 +350,7 @@ fn pdqsortFunc[S: []E, E](mut data: S, mut a: int, mut b: int, mut limit: int, c a = mid + 1 } else { wasBalanced = rightLen >= balanceThreshold - pdqsortFunc(data, mid + 1, b, limit, cmp) + pdqsortFunc(data, mid+1, b, limit, cmp) b = mid } } diff --git a/std/slices/sortordered.jule b/std/slices/sortordered.jule index fff3ce635..e02df76f0 100644 --- a/std/slices/sortordered.jule +++ b/std/slices/sortordered.jule @@ -60,7 +60,7 @@ fn insertionSort[E: ordered](mut &data: []E, a: int, b: int) { fn siftDown[E: ordered](mut &data: []E, lo: int, hi: int, first: int) { mut root := lo for { - mut child := 2 * root + 1 + mut child := 2*root + 1 if child >= hi { break } @@ -102,8 +102,8 @@ fn breakPatterns[E: ordered](mut &data: []E, a: int, b: int) { mut random := xorshift(length) modulus := nextPowerOfTwo(length) - mut idx := a + (length / 4) * 2 - 1 - for idx <= a+(length / 4)*2+1; idx++ { + mut idx := a + (length/4)*2 - 1 + for idx <= a+(length/4)*2+1; idx++ { mut other := int(uint(xorshiftNext(random)) & (modulus - 1)) if other >= length { other -= length @@ -132,7 +132,7 @@ fn median[E: ordered](data: []E, mut a: int, mut b: int, mut c: int, mut &swaps: // Finds the median of data[a - 1], data[a], data[a + 1] and stores the index into a. fn medianAdjacent[E: ordered](data: []E, a: int, mut &swaps: int): int { - ret median(data, a - 1, a, a + 1, swaps) + ret median(data, a-1, a, a+1, swaps) } // Chooses a pivot in data[a:b]. @@ -147,9 +147,9 @@ fn choosePivot[E: ordered](mut &data: []E, a: int, b: int): (pivot: int, hint: s l := b - a mut swaps := 0 - mut i := a + l / 4 * 1 - mut j := a + l / 4 * 2 - mut k := a + l / 4 * 3 + mut i := a + l/4*1 + mut j := a + l/4*2 + mut k := a + l/4*3 if l >= 8 { if l >= shortestNinther { @@ -358,7 +358,7 @@ fn pdqsort[E: ordered](mut &data: []E, mut a: int, mut b: int, mut limit: int) { a = mid + 1 } else { wasBalanced = rightLen >= balanceThreshold - pdqsort(data, mid + 1, b, limit) + pdqsort(data, mid+1, b, limit) b = mid } } diff --git a/std/strings/strings.jule b/std/strings/strings.jule index e6d54719b..e3b4cf0ca 100644 --- a/std/strings/strings.jule +++ b/std/strings/strings.jule @@ -82,7 +82,7 @@ loop: // returns -1 if not exist any match. Starts searching at right // of string to left. fn FindLast(s: str, sub: str): int { - ret FindLastAt(s, sub, len(s) - 1) + ret FindLastAt(s, sub, len(s)-1) } // Returns index of first matched item with finder function, @@ -132,7 +132,7 @@ fn FindFnLastAt(s: str, mut i: int, f: fn(mut rune): bool): int { // returns -1 if not exist any match. Starts searching at right // of string to left. fn FindFnLast(s: str, f: fn(mut rune): bool): int { - ret FindFnLastAt(s, len(s) - 1, f) + ret FindFnLastAt(s, len(s)-1, f) } // Returns index of first matched item with specified byte, @@ -294,7 +294,7 @@ fn Replace(s: str, sub: str, new: str, mut n: int): str { n = m } - mut ss := StrBuilder.New((len(s) + n * (len(new) - len(sub))) + 1) + mut ss := StrBuilder.New((len(s) + n*(len(new)-len(sub))) + 1) mut i := 0 for n > 0; n-- { j := FindAt(s, sub, i) diff --git a/std/sys/net.jule b/std/sys/net.jule index d68e9c6c7..e7f44a1f8 100755 --- a/std/sys/net.jule +++ b/std/sys/net.jule @@ -5,7 +5,7 @@ use integ for std::jule::integrated::{Char} #typedef -cpp struct fd_set {} +cpp struct fd_set{} #typedef cpp struct timeval { @@ -21,7 +21,7 @@ cpp struct in6_addr { s6_addr: [16]byte } -cpp struct sockaddr {} +cpp struct sockaddr{} cpp struct sockaddr_in { sin_len: byte diff --git a/std/sys/net_windows.jule b/std/sys/net_windows.jule index 29b71df29..99a129b66 100755 --- a/std/sys/net_windows.jule +++ b/std/sys/net_windows.jule @@ -12,7 +12,7 @@ cpp use "" cpp use "" #typedef -cpp struct WSADATA {} +cpp struct WSADATA{} #cdef cpp fn MAKEWORD(a: int, b: int): u16 diff --git a/std/sys/syscall_unix.jule b/std/sys/syscall_unix.jule index 52ce83165..f5fde1fe8 100644 --- a/std/sys/syscall_unix.jule +++ b/std/sys/syscall_unix.jule @@ -8,7 +8,7 @@ cpp use "" cpp use "" #typedef -cpp struct DIR {} +cpp struct DIR{} cpp struct dirent { d_name: *Char diff --git a/std/time/duration.jule b/std/time/duration.jule index 6842089f2..8555c4e44 100644 --- a/std/time/duration.jule +++ b/std/time/duration.jule @@ -6,7 +6,7 @@ type DurInt: i64 // Duration is the time between two times. -struct Duration {} +struct Duration{} impl Duration { const min = DurInt.Min @@ -54,21 +54,21 @@ impl Duration { static fn Seconds(d: DurInt): f64 { sec := d / Duration.Second nsec := d % Duration.Second - ret f64(sec) + f64(nsec) / 1e9 + ret f64(sec) + f64(nsec)/1e9 } // Returns duration as floating-point minutes. static fn Minutes(d: DurInt): f64 { min := d / Duration.Minute nsec := d % Duration.Minute - ret f64(min) + f64(nsec) / (60 * 1e9) + ret f64(min) + f64(nsec)/(60*1e9) } // Returns duration as floating-point hours. static fn Hours(d: DurInt): f64 { hour := d / Duration.Hour nsec := d % Duration.Hour - ret f64(hour) + f64(nsec) / (60 * 60 * 1e9) + ret f64(hour) + f64(nsec)/(60*60*1e9) } // Returns absolute value of duration. @@ -88,7 +88,7 @@ impl Duration { // second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure // that the leading digit is non-zero. The zero duration formats as 0s. static fn Str(d: DurInt): str { - mut buf := make([]byte, 1 << 5) + mut buf := make([]byte, 1<<5) n := formatDuration(d, buf) buf = buf[n:] ret str(buf) @@ -143,14 +143,14 @@ fn formatDuration(d: DurInt, mut buf: []byte): int { w, u = fmtFrac(buf[:w], u, 9) // u is now integer seconds - w = fmtInt(buf[:w], u % 60) + w = fmtInt(buf[:w], u%60) u /= 60 // u is now integer minutes if u > 0 { w-- buf[w] = 'm' - w = fmtInt(buf[:w], u % 60) + w = fmtInt(buf[:w], u%60) u /= 60 // u is now integer hours @@ -206,7 +206,7 @@ fn fmtInt(mut buf: []byte, mut v: u64): int { } else { for v > 0 { w-- - buf[w] = byte(v % 10) + '0' + buf[w] = byte(v%10) + '0' v /= 10 } } diff --git a/std/time/time.jule b/std/time/time.jule index 49e2fec57..cff918d93 100644 --- a/std/time/time.jule +++ b/std/time/time.jule @@ -21,13 +21,13 @@ const nsecPerMsec = 1000000 const nsecPerSec = nsecPerMsec * msecPerSec const msecPerSec = 1000 const daysPerY = 365 -const daysPer400Y = daysPerY * 400 + 97 -const daysPer100Y = daysPerY * 100 + 24 -const daysPer4Y = daysPerY * 4 + 1 +const daysPer400Y = daysPerY*400 + 97 +const daysPer100Y = daysPerY*100 + 24 +const daysPer4Y = daysPerY*4 + 1 // 2000-03-01 (mod 400 year, immediately after feb29 const _2000_03_01 = 946684800 -const modApoch = _2000_03_01 + day * (31 + 29) +const modApoch = _2000_03_01 + day*(31+29) // Days in month. static mdays: [...]u64 = [31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29] @@ -172,7 +172,7 @@ impl Time { } mut t := AbsTime{} - t.Year = remYears + 4 * qCycles + 100 * cCycles + 400 * qcCycles + 100 + t.Year = remYears + 4*qCycles + 100*cCycles + 400*qcCycles + 100 t.Month = months + 2 if t.Month >= 12 { t.Month -= 12 @@ -201,11 +201,11 @@ fn unix(): UnixTime { fn unixYearToSeconds(y: TimeData, mut &leap: bool): UnixTime { if y-2 <= 136 { mut leaps := (y - 68) >> 2 - leap = (y - 68)&3 == 0 + leap = (y-68)&3 == 0 if leap { leaps-- } - ret 31536000 * (y - 70) + day * leaps + ret 31536000*(y-70) + day*leaps } mut leaps := TimeData(0) @@ -247,12 +247,12 @@ fn unixYearToSeconds(y: TimeData, mut &leap: bool): UnixTime { } } - leaps += 97 * cycles + 24 * centuries + leaps += 97*cycles + 24*centuries if leap { leaps++ } - ret (y - 100) * 31536000 + leaps * day + 946684800 + day + ret (y-100)*31536000 + leaps*day + 946684800 + day } fn unixMonthToSeconds(m: TimeData, leap: bool): UnixTime { diff --git a/std/unicode/letter.jule b/std/unicode/letter.jule index 3660f7f73..82c907d79 100644 --- a/std/unicode/letter.jule +++ b/std/unicode/letter.jule @@ -131,7 +131,7 @@ fn to(case: int, r: rune, caseRange: []CaseRange): (mappedRune: rune, foundMappi mut lo := 0 mut hi := len(caseRange) for lo < hi { - m := lo + (hi - lo) / 2 + m := lo + (hi-lo)/2 cr := caseRange[m] if rune(cr.Lo) <= r && r <= rune(cr.Hi) { delta := cr.Delta[case] @@ -146,7 +146,7 @@ fn to(case: int, r: rune, caseRange: []CaseRange): (mappedRune: rune, foundMappi // bit in the sequence offset. // The constants UpperCase and TitleCase are even while LowerCase // is odd so we take the low bit from case. - ret rune(cr.Lo) + ((r - rune(cr.Lo)) & ^1 | rune(case & 1)), true + ret rune(cr.Lo) + ((r-rune(cr.Lo))&^1 | rune(case&1)), true } ret r + delta, true } @@ -208,7 +208,7 @@ fn is16(ranges: []Range16, r: u16): bool { mut lo := 0 mut hi := len(ranges) for lo < hi { - m := lo + (hi - lo) / 2 + m := lo + (hi-lo)/2 range := &ranges[m] unsafe { if range.Lo <= r && r <= range.Hi { @@ -245,7 +245,7 @@ fn is32(ranges: []Range32, r: u32): bool { mut lo := 0 mut hi := len(ranges) for lo < hi { - m := lo + (hi - lo) / 2 + m := lo + (hi-lo)/2 range := &ranges[m] unsafe { if range.Lo <= r && r <= range.Hi { diff --git a/std/unicode/utf16/utf16.jule b/std/unicode/utf16/utf16.jule index 11daad8db..60eed07f8 100644 --- a/std/unicode/utf16/utf16.jule +++ b/std/unicode/utf16/utf16.jule @@ -67,7 +67,7 @@ fn IsSurrogate(r: rune): bool { // the Unicode replacement code point U+FFFD. fn DecodeRune(r1: rune, r2: rune): rune { if surr1 <= r1 && r1 < surr2 && surr2 <= r2 && r2 < surr3 { - ret (r1 - surr1) << 10 | (r2 - surr2) + surrSelf + ret (r1-surr1)<<10 | (r2 - surr2) + surrSelf } ret replacementChar } @@ -80,7 +80,7 @@ fn EncodeRune(mut r: rune): (r1: rune, r2: rune) { ret replacementChar, replacementChar } r -= surrSelf - ret surr1 + (r >> 10) & 0x3ff, surr2 + r & 0x3ff + ret surr1 + (r>>10)&0x3ff, surr2 + r&0x3ff } // Returns the UTF-16 encoding of the Unicode code point sequence s. diff --git a/std/unicode/utf8/utf8.jule b/std/unicode/utf8/utf8.jule index f7e106d58..901dc9193 100644 --- a/std/unicode/utf8/utf8.jule +++ b/std/unicode/utf8/utf8.jule @@ -73,9 +73,9 @@ const mask2 = 0b00011111 const mask3 = 0b00001111 const mask4 = 0b00000111 -const rune1max = 1 << 7 - 1 -const rune2max = 1 << 11 - 1 -const rune3max = 1 << 16 - 1 +const rune1max = 1<<7 - 1 +const rune2max = 1<<11 - 1 +const rune3max = 1<<16 - 1 // The default lowest and highest continuation byte. const locb = 0b10000000 @@ -190,7 +190,7 @@ fn DecodeRune(p: []byte): (r: rune, size: int) { // handling the ASCII and invalid cases accordingly. This mask-and-or // approach prevents an additional branch. mask := rune(x) << 31 >> 31 // Create 0x0000 or 0xFFFF. - ret rune(p[0]) & ^mask | RuneError & mask, 1 + ret rune(p[0])&^mask | RuneError&mask, 1 } sz := int(x & 7) accept := acceptRanges[x>>4] @@ -202,20 +202,20 @@ fn DecodeRune(p: []byte): (r: rune, size: int) { ret RuneError, 1 } if sz <= 2 { // <= instead of == to help the compiler eliminate some bounds checks - ret rune(p0 & mask2) << 6 | rune(b1 & maskX), 2 + ret rune(p0&mask2)<<6 | rune(b1&maskX), 2 } b2 := p[2] if b2 < locb || hicb < b2 { ret RuneError, 1 } if sz <= 3 { - ret rune(p0 & mask3) << 12 | rune(b1 & maskX) << 6 | rune(b2 & maskX), 3 + ret rune(p0&mask3)<<12 | rune(b1&maskX)<<6 | rune(b2&maskX), 3 } b3 := p[3] if b3 < locb || hicb < b3 { ret RuneError, 1 } - ret rune(p0 & mask4) << 18 | rune(b1 & maskX) << 12 | rune(b2 & maskX) << 6 | rune(b3 & maskX), 4 + ret rune(p0&mask4)<<18 | rune(b1&maskX)<<12 | rune(b2&maskX)<<6 | rune(b3&maskX), 4 } // Is like DecodeRune but its input is a string. If s is empty @@ -237,7 +237,7 @@ fn DecodeRuneStr(s: str): (r: rune, size: int) { // handling the ASCII and invalid cases accordingly. This mask-and-or // approach prevents an additional branch. mask := rune(x) << 31 >> 31 // Create 0x0000 or 0xFFFF. - ret rune(s[0]) & ^mask | RuneError & mask, 1 + ret rune(s[0])&^mask | RuneError&mask, 1 } sz := int(x & 7) accept := acceptRanges[x>>4] @@ -249,20 +249,20 @@ fn DecodeRuneStr(s: str): (r: rune, size: int) { ret RuneError, 1 } if sz <= 2 { // <= instead of == to help the compiler eliminate some bounds checks - ret rune(s0 & mask2) << 6 | rune(s1 & maskX), 2 + ret rune(s0&mask2)<<6 | rune(s1&maskX), 2 } s2 := s[2] if s2 < locb || hicb < s2 { ret RuneError, 1 } if sz <= 3 { - ret rune(s0 & mask3) << 12 | rune(s1 & maskX) << 6 | rune(s2 & maskX), 3 + ret rune(s0&mask3)<<12 | rune(s1&maskX)<<6 | rune(s2&maskX), 3 } s3 := s[3] if s3 < locb || hicb < s3 { ret RuneError, 1 } - ret rune(s0 & mask4) << 18 | rune(s1 & maskX) << 12 | rune(s2 & maskX) << 6 | rune(s3 & maskX), 4 + ret rune(s0&mask4)<<18 | rune(s1&maskX)<<12 | rune(s2&maskX)<<6 | rune(s3&maskX), 4 } // Unpacks the last UTF-8 encoding in p and returns the rune and @@ -379,22 +379,22 @@ fn EncodeRune(mut p: []byte, mut r: rune): int { p[0] = byte(r) ret 1 | i <= rune2max: - p[0] = t2 | byte(r >> 6) - p[1] = tx | byte(r) & maskX + p[0] = t2 | byte(r>>6) + p[1] = tx | byte(r)&maskX ret 2 | i > MaxRune | surrogateMin <= i && i <= surrogateMax: r = RuneError fall | i <= rune3max: - p[0] = t3 | byte(r >> 12) - p[1] = tx | byte(r >> 6) & maskX - p[2] = tx | byte(r) & maskX + p[0] = t3 | byte(r>>12) + p[1] = tx | byte(r>>6)&maskX + p[2] = tx | byte(r)&maskX ret 3 |: - p[0] = t4 | byte(r >> 18) - p[1] = tx | byte(r >> 12) & maskX - p[2] = tx | byte(r >> 6) & maskX - p[3] = tx | byte(r) & maskX + p[0] = t4 | byte(r>>18) + p[1] = tx | byte(r>>12)&maskX + p[2] = tx | byte(r>>6)&maskX + p[3] = tx | byte(r)&maskX ret 4 } } @@ -414,14 +414,14 @@ fn appendRuneNonASCII(mut p: []byte, mut r: rune): []byte { i := u32(r) match { | i <= rune2max: - ret append(p, t2 | byte(r >> 6), tx | byte(r) & maskX) + ret append(p, t2|byte(r>>6), tx|byte(r)&maskX) | i > MaxRune | surrogateMin <= i && i <= surrogateMax: r = RuneSelf fall | i <= rune3max: - ret append(p, t3 | byte(r >> 12), tx | byte(r >> 6) & maskX, tx | byte(r) & maskX) + ret append(p, t3|byte(r>>12), tx|byte(r>>6)&maskX, tx|byte(r)&maskX) |: - ret append(p, t4 | byte(r >> 18), tx | byte(r >> 12) & maskX, tx | byte(r >> 6) & maskX, tx | byte(r) & maskX) + ret append(p, t4|byte(r>>18), tx|byte(r>>12)&maskX, tx|byte(r>>6)&maskX, tx|byte(r)&maskX) } } @@ -526,9 +526,9 @@ fn Valid(p: []byte): bool { for len(cp) >= 8 { // Combining two 32 bit loads allows the same code to be used // for 32 and 64 bit platforms. - first32 := u32(cp[0]) | u32(cp[1]) << 8 | u32(cp[2]) << 16 | u32(cp[3]) << 24 - second32 := u32(cp[4]) | u32(cp[5]) << 8 | u32(cp[6]) << 16 | u32(cp[7]) << 24 - if (first32 | second32)&0x80808080 != 0 { + first32 := u32(cp[0]) | u32(cp[1])<<8 | u32(cp[2])<<16 | u32(cp[3])<<24 + second32 := u32(cp[4]) | u32(cp[5])<<8 | u32(cp[6])<<16 | u32(cp[7])<<24 + if (first32|second32)&0x80808080 != 0 { // Found a non ASCII byte (>= RneSelf). break } @@ -577,9 +577,9 @@ fn ValidStr(mut s: str): bool { for len(s) >= 8 { // Combining two 32 bit loads allows the same code to be used // for 32 and 64 bit platforms. - first32 := u32(s[0]) | u32(s[1]) << 8 | u32(s[2]) << 16 | u32(s[3]) << 24 - second32 := u32(s[4]) | u32(s[5]) << 8 | u32(s[6]) << 16 | u32(s[7]) << 24 - if (first32 | second32)&0x80808080 != 0 { + first32 := u32(s[0]) | u32(s[1])<<8 | u32(s[2])<<16 | u32(s[3])<<24 + second32 := u32(s[4]) | u32(s[5])<<8 | u32(s[6])<<16 | u32(s[7])<<24 + if (first32|second32)&0x80808080 != 0 { // Found a non ASCII byte (>= RuneSelf). break }