Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(176)

Side by Side Diff: go/exact/exact.go

Issue 37820052: code review 37820052: go.tools/go/exact: fix bug introduced with CL 41170043 (Closed)
Patch Set: diff -r 3fbe8ee3708b https://code.google.com/p/go.tools Created 10 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package exact implements mathematically exact values 5 // Package exact implements mathematically exact values
6 // and operations for untyped Go constant values. 6 // and operations for untyped Go constant values.
7 // 7 //
8 // A special Unknown value may be used when a constant 8 // A special Unknown value may be used when a constant
9 // value is unknown due to an error; operations on unknown 9 // value is unknown due to an error; operations on unknown
10 // values produce unknown values. 10 // values produce unknown values.
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 default: 423 default:
424 panic(fmt.Sprintf("%v not Int or Float", x)) 424 panic(fmt.Sprintf("%v not Int or Float", x))
425 } 425 }
426 return normComplex(rat0, im) 426 return normComplex(rat0, im)
427 } 427 }
428 428
429 // Real returns the real part of x, which must be a numeric or unknown value. 429 // Real returns the real part of x, which must be a numeric or unknown value.
430 // If x is Unknown, the result is Unknown. 430 // If x is Unknown, the result is Unknown.
431 func Real(x Value) Value { 431 func Real(x Value) Value {
432 switch x := x.(type) { 432 switch x := x.(type) {
433 » case unknownVal: 433 » case unknownVal, int64Val, intVal, floatVal:
434 return x 434 return x
435 case int64Val, intVal, floatVal:
436 return int64Val(0)
437 case complexVal: 435 case complexVal:
438 return normFloat(x.re) 436 return normFloat(x.re)
439 } 437 }
440 panic(fmt.Sprintf("%v not numeric", x)) 438 panic(fmt.Sprintf("%v not numeric", x))
441 } 439 }
442 440
443 // Imag returns the imaginary part of x, which must be a numeric or unknown valu e. 441 // Imag returns the imaginary part of x, which must be a numeric or unknown valu e.
444 // If x is Unknown, the result is Unknown. 442 // If x is Unknown, the result is Unknown.
445 func Imag(x Value) Value { 443 func Imag(x Value) Value {
446 switch x := x.(type) { 444 switch x := x.(type) {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 return x <= y 889 return x <= y
892 case token.GTR: 890 case token.GTR:
893 return x > y 891 return x > y
894 case token.GEQ: 892 case token.GEQ:
895 return x >= y 893 return x >= y
896 } 894 }
897 } 895 }
898 896
899 panic(fmt.Sprintf("invalid comparison %v %s %v", x, op, y)) 897 panic(fmt.Sprintf("invalid comparison %v %s %v", x, op, y))
900 } 898 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b