github.com/XiaoMi/Gaea@v1.2.5/parser/tidb-types/compare.go (about) 1 // Copyright 2015 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package types 15 16 // CompareInt64 returns an integer comparing the int64 x to y. 17 func CompareInt64(x, y int64) int { 18 if x < y { 19 return -1 20 } else if x == y { 21 return 0 22 } 23 24 return 1 25 } 26 27 // CompareUint64 returns an integer comparing the uint64 x to y. 28 func CompareUint64(x, y uint64) int { 29 if x < y { 30 return -1 31 } else if x == y { 32 return 0 33 } 34 35 return 1 36 } 37 38 // CompareFloat64 returns an integer comparing the float64 x to y. 39 func CompareFloat64(x, y float64) int { 40 if x < y { 41 return -1 42 } else if x == y { 43 return 0 44 } 45 46 return 1 47 } 48 49 // CompareString returns an integer comparing the string x to y. 50 func CompareString(x, y string) int { 51 if x < y { 52 return -1 53 } else if x == y { 54 return 0 55 } 56 57 return 1 58 }