Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 14 total
Thread Problem Conversion String to Int
Tue, Oct 6 2015 9:40 AMPermanent Link

Pasquale

Web Pos srl

I have this code

Var
Identificativo   : String;
FIdentificativo : Integer;

....
  PEditIdentificativo.Text := '997000000023529177';

   Identificativo          := Copy(PEditIdentificativo.Text,1,16);
   FIdentificativo       := StrToInt(Identificativo);
   Label13.Caption    := IntToStr(FIdentificativo);


why the value the print label13.caption is  9970000000235292 ?

the value correct is 9970000000235291
Tue, Oct 6 2015 9:53 AMPermanent Link

Raul

Globestar Systems

Team Elevate Team Elevate

On 10/6/2015 9:40 AM, Pasquale wrote:
>     PEditIdentificativo.Text := '997000000023529177';
> why the value the print label13.caption is  9970000000235292 ?
> the value correct is 9970000000235291

This appears to be out of range of Javascript int values.

Valid max values for javascript are +/- 9007199254740991 (see
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).

in EWB manual int is defined same way as 52-bit, signed integer value.

Raul
Tue, Oct 6 2015 10:12 AMPermanent Link

Pasquale

Web Pos srl

ok .

i have this code :

Var
Identificativo : String;
Controllo      : String;
FIdentificativo   : Double;
DivIdentificativo : Integer;
DivControllo      : Integer;
Check             : Integer;
SCheck            : String;

Begin

   Identificativo     := Copy(PEditIdentificativo.Text,1,16);
   Controllo          := Copy(PEditIdentificativo.Text,17,2);
   FIdentificativo    := StrToFloat(Identificativo);    
   DivIdentificativo  := FIdentificativo DIV 93;
   DivIdentificativo  := DivIdentificativo * 93;
   Check              := FIdentificativo - DivIdentificativo;
   SCheck             := FloatToStr(Check);

   IF Length(SCheck) = 1 Then
                           SCheck := '0' + SCheck;
                                                  
   IF (StrToFloat(SCheck)-StrToFloat(Controllo)) <> 0 Then
   Begin
     MessageDlg('IDENTIFICATIVO non corretto !','Attenzione',mtError,[mbOk],mbOk,nil,True);
     Exit;
   End;

compilator generate error of DivIdentificativo  := FIdentificativo DIV 93; why FIdentificativo is Double

how do I fix ?


Raul wrote:

On 10/6/2015 9:40 AM, Pasquale wrote:
>     PEditIdentificativo.Text := '997000000023529177';
> why the value the print label13.caption is  9970000000235292 ?
> the value correct is 9970000000235291

This appears to be out of range of Javascript int values.

Valid max values for javascript are +/- 9007199254740991 (see
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).

in EWB manual int is defined same way as 52-bit, signed integer value.

Raul
Tue, Oct 6 2015 11:04 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Pasquale,

<< compilator generate error of DivIdentificativo  := FIdentificativo DIV 93; why FIdentificativo is Double >>

You cannot use floating-point values with the DIV operator (integer divide), you need to use the / operator instead.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Oct 6 2015 11:16 AMPermanent Link

Pasquale

Web Pos srl

All right, and what function then I take the integer part ?




Tim Young [Elevate Software] wrote:

Pasquale,

<< compilator generate error of DivIdentificativo  := FIdentificativo DIV 93; why FIdentificativo is Double >>

You cannot use floating-point values with the DIV operator (integer divide), you need to use the / operator instead.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Oct 6 2015 11:22 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Pasquale,

<< All right, and what function then I take the integer part ? >>

The integer part of *what* ?  The floating-point value ?

If you want the integer portion of a floating-point value, then all of these functions will provide it in various ways:

http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Trunc
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Round
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Floor
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Ceil

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Oct 6 2015 11:31 AMPermanent Link

Pasquale

Web Pos srl

ok tanks


Tim Young [Elevate Software] wrote:

Pasquale,

<< All right, and what function then I take the integer part ? >>

The integer part of *what* ?  The floating-point value ?

If you want the integer portion of a floating-point value, then all of these functions will provide it in various ways:

http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Trunc
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Round
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Floor
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Ceil

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Oct 8 2015 6:57 AMPermanent Link

Pasquale

Web Pos srl

Var
FIdentificativo   : Double;
Begin

FIdentificativo       := StrToFloat('9970000000235291');
Label13.Caption    := FloatToStr(FIdentificativo);

why the label13.caption visualized 9970000000235292 ?





Pasquale wrote:

ok tanks


Tim Young [Elevate Software] wrote:

Pasquale,

<< All right, and what function then I take the integer part ? >>

The integer part of *what* ?  The floating-point value ?

If you want the integer portion of a floating-point value, then all of these functions will provide it in various ways:

http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Trunc
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Round
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Floor
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Ceil

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Oct 8 2015 1:49 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Pasquale,

<< why the label13.caption visualized 9970000000235292 ? >>

Did you read Raul's reply to you ?

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Oct 12 2015 4:22 AMPermanent Link

Pasquale

Web Pos srl

Yes i read.

I converted the variable Identificativo in Double .

the range DOUBLE is not greater ?





Tim Young [Elevate Software] wrote:

Pasquale,

<< why the label13.caption visualized 9970000000235292 ? >>

Did you read Raul's reply to you ?

Tim Young
Elevate Software
www.elevatesoft.com
Page 1 of 2Next Page
Jump to Page:  1 2
Image