fix overflow

This commit is contained in:
Suyono 2025-05-17 12:22:28 +10:00
parent 8e2ca9de19
commit ffe10b11a3
4 changed files with 2 additions and 27 deletions

View File

@ -47,7 +47,3 @@ func (b BiByteUnit) Tebi() float64 {
func (b BiByteUnit) Pebi() float64 { func (b BiByteUnit) Pebi() float64 {
return float64(b / PebiByte) return float64(b / PebiByte)
} }
func (b BiByteUnit) Exbi() float64 {
return float64(b / ExbiByte)
}

View File

@ -19,11 +19,11 @@ package sizes
import "math" import "math"
func (b BitUnit) AsByte() ByteUnit { func (b BitUnit) AsByte() ByteUnit {
return ByteUnit(math.Ceil(float64(b / 8))) return ByteUnit(math.Ceil(float64(b) / float64(8)))
} }
func (b BitUnit) AsBiByte() BiByteUnit { func (b BitUnit) AsBiByte() BiByteUnit {
return BiByteUnit(math.Ceil(float64(b / 8))) return BiByteUnit(math.Ceil(float64(b) / float64(8)))
} }
func (b BitUnit) AsBit() BitUnit { func (b BitUnit) AsBit() BitUnit {
@ -49,11 +49,3 @@ func (b BitUnit) Tera() float64 {
func (b BitUnit) Peta() float64 { func (b BitUnit) Peta() float64 {
return float64(b / PetaBit) return float64(b / PetaBit)
} }
func (b BitUnit) Exa() float64 {
return float64(b / ExaBit)
}
func (b BitUnit) Zeta() float64 {
return float64(b / ZetaBit)
}

View File

@ -47,11 +47,3 @@ func (b ByteUnit) Tera() float64 {
func (b ByteUnit) Peta() float64 { func (b ByteUnit) Peta() float64 {
return float64(b / PetaByte) return float64(b / PetaByte)
} }
func (b ByteUnit) Exa() float64 {
return float64(b / ExaByte)
}
func (b ByteUnit) Zeta() float64 {
return float64(b / ZetaByte)
}

View File

@ -29,8 +29,6 @@ const (
GigaBit BitUnit = 1000000000 GigaBit BitUnit = 1000000000
TeraBit BitUnit = 1000000000000 TeraBit BitUnit = 1000000000000
PetaBit BitUnit = 1000000000000000 PetaBit BitUnit = 1000000000000000
ExaBit BitUnit = 10000000000000000000
ZetaBit BitUnit = 10000000000000000000000
) )
const ( const (
@ -40,8 +38,6 @@ const (
GigaByte ByteUnit = 1000000000 GigaByte ByteUnit = 1000000000
TeraByte ByteUnit = 1000000000000 TeraByte ByteUnit = 1000000000000
PetaByte ByteUnit = 1000000000000000 PetaByte ByteUnit = 1000000000000000
ExaByte ByteUnit = 10000000000000000000
ZetaByte ByteUnit = 10000000000000000000000
) )
const ( const (
@ -51,5 +47,4 @@ const (
GibiByte GibiByte
TebiByte TebiByte
PebiByte PebiByte
ExbiByte
) )