Skip to content

Commit

Permalink
Add .Add() and .Sub() to f64.Int for easier use in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwilkes committed Jul 31, 2023
1 parent 942b2c6 commit b1b2e6a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/pkg/term v1.1.0
github.com/stretchr/testify v1.8.4
github.com/yookoala/realpath v1.0.0
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691
golang.org/x/image v0.9.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Y
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY=
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 h1:/yRP+0AN7mf5DkD3BAI6TOFnd51gEoDEb8o35jIFtgw=
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.9.0 h1:QrzfX26snvCM20hIhBwuHI/ThTg18b/+kcKdXHvnR+g=
golang.org/x/image v0.9.0/go.mod h1:jtrku+n79PfroUbvDdeUWMAI+heR786BofxrbiSF+J0=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand Down
14 changes: 14 additions & 0 deletions xmath/fixed/f64/f64.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ func FromStringForced[T fixed.Dx](str string) Int[T] {
return f
}

// Add adds this value to the passed-in value, returning a new value. Note that this method is only provided to make
// text templates easier to use with these objects, since you can just add two Int[T] values together like they were
// primitive types.
func (f Int[T]) Add(value Int[T]) Int[T] {
return f + value
}

// Sub subtracts the passed-in value from this value, returning a new value. Note that this method is only provided to
// make text templates easier to use with these objects, since you can just subtract two Int[T] values together like
// they were primitive types.
func (f Int[T]) Sub(value Int[T]) Int[T] {
return f - value
}

// Mul multiplies this value by the passed-in value, returning a new value.
func (f Int[T]) Mul(value Int[T]) Int[T] {
return f * value / Int[T](Multiplier[T]())
Expand Down

0 comments on commit b1b2e6a

Please sign in to comment.