[英]strtoint not be getting the same value
在我的第二個變量中'm試圖將字符串轉換為整數,但是值不一樣!
變量“ app”正在接收“ 1”,但它正在接收“ 0001”。
這是我的代碼:
function isnew(Ls:string):Boolean;
var
appvs,app:Integer;
begin
appvs:=StrToInt(StringReplace(GetAppVersionStr,'.',''[rfReplaceAll]));
app:= strtoint(Ls); // the value in ls is 0001 but receive in app 1
if app > appvs then
result:= True
else
result:= false;
end;
app:Integer
保存Ls:string
的整數表示形式。
您不能“強制”將整數表示為4位數的值,除非其值確實在[1000,9999]
。 您的顯示可以是因為這是一個字符串。
數字可以有不同的表示形式。 因此1和0001是相同數字的不同表示形式。 Integer
存儲數字而不是表示形式。 因此,您不能在Integer
中將1與0001相區別。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.