Skip to content

How do I match a float32? #206

Closed Answered by pashagolub
nchelluri asked this question in Q&A
Discussion options

You must be logged in to vote

Why not just

type FloatArgument float64

const epsilon = 0.000001

func (a FloatArgument) Match(v interface{}) bool {
	f, ok := v.(float64)
	if !ok {
		return false
	}
	return math.Abs(f-float64(a)) <= epsilon
}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@nchelluri
Comment options

Answer selected by nchelluri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants