IsZero returns 1 if the given variable is zero, otherwise returns 0.
(i1 frontend.Variable)
| 340 | |
| 341 | // IsZero returns 1 if the given variable is zero, otherwise returns 0. |
| 342 | func (builder *builder) IsZero(i1 frontend.Variable) frontend.Variable { |
| 343 | a := builder.toVariableId(i1) |
| 344 | if c, ok := builder.constantValue(a); ok { |
| 345 | if c.IsZero() { |
| 346 | return builder.toVariable(builder.tOne) |
| 347 | } |
| 348 | return builder.toVariable(constraint.Element{}) |
| 349 | } |
| 350 | builder.instructions = append(builder.instructions, irsource.Instruction{ |
| 351 | Type: irsource.IsZero, |
| 352 | X: a, |
| 353 | }) |
| 354 | return builder.addVar() |
| 355 | } |
| 356 | |
| 357 | // Cmp compares i1 and i2 and returns 1 if i1>i2, 0 if i1=i2, -1 if i1<i2. |
| 358 | func (builder *builder) Cmp(i1, i2 frontend.Variable) frontend.Variable { |
no test coverage detected