我正在搜索一个问题的评论。
我有一个4位数字,如3521,问题是我需要找到前两位数大于后两位的数字。
答案 0 :(得分:1)
假设你的号码是lnMyNumber:
lnMyNumber = 3521
? (Val(Left(Str(lnMyNumber, 4, 0),2)) > Val(right(Str(lnMyNumber, 4, 0),2)))
答案 1 :(得分:0)
命令窗口示例:
LOCAL unknownType
unknownType = 3521
? CompareSumsOfTwoBytePairs(unknownType) && returns true
unknownType = "3521"
? CompareSumsOfTwoBytePairs(unknownType) && returns true
unknownType = "YZAB"
? CompareSumsOfTwoBytePairs(unknownType) && returns true
unknownType = 35210
? CompareSumsOfTwoBytePairs(unknownType) && too long, returns false
* The following unexpected types return all false:
unknownType = .F.
? CompareSumsOfTwoBytePairs(unknownType)
unknownType = .Null.
? CompareSumsOfTwoBytePairs(unknownType)
unknownType = CREATEOBJECT("Form")
? CompareSumsOfTwoBytePairs(unknownType)
unknownType = DATE(2015, 2, 7)
? CompareSumsOfTwoBytePairs(unknownType)
FUNCTION CompareSumsOfTwoBytePairs(u)
LOCAL c
c = TRANSFORM(u)
RETURN LEN(c) == 4 AND (SUBSTR(c, 1, 2) > SUBSTR(c, 3, 2))
ENDFUNC
答案 2 :(得分:0)
另一种选择是将数字保持为数字与强制字符串转换。
n = 3521
? INT( n/100 ) > n-(INT(n/100)*100)
n/100 = 35.21... the int leaves just 35
同样的基础在另一半......
n-(INT(n/100)*100)
3521 - ( INT( 3521/100) * 100 )
= 3521 - ( 35 * 100 )
= 3521 - 3500 = 21
so 35 > 21
答案 3 :(得分:0)
这是一个完整的代码,而不是你可以放入一个函数
local lnVal, llReturn
lnVal=35821
llReturn=left(trans(lnVal),2)>right(trans(lnVal),2)
return llReturn