Int() creates a Double???

Results 1 to 2 of 2

Thread: Int() creates a Double???

  1. #1
    Dean C Guest

    Default Int() creates a Double???

    In playing around with variable types I noticed that put the result of the Int() function call into an unknown variable type causes that variable to become a double.<BR><BR>For Example, the following code:<BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;% Option Explicit %&#062;&#060;% <BR> &#039Declare the variables<BR> Dim iVar1, iVar2<BR> <BR> &#039Load values<BR> iVar1 = 5<BR> iVar2 = Int("5")<BR> <BR> &#039Display variable types<BR> Response.Write ("iVar1: " & TypeName(iVar1) & "<BR>")<BR> Response.Write ("iVar2: " & TypeName(iVar2))<BR> %&#062;<BR><BR>...produces the output page:<BR><BR>iVar1: Integer<BR>iVar2: Double <BR><BR>Has anyone else run into this?<BR>Tested using IIS 5 (Win2KPro) and IE5.01<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Int() creates a Double???

    Yes. That is what it is supposed to do.<BR><BR>Perhaps you are confusing Int( ) with CInt( ) ???<BR><BR>Consider: If you had a number that was too large to be represented as an integer, wouldn&#039t you still want Int to work?<BR><BR>As in Int(12345678912.6) ??<BR><BR>The number 12345678912 is too large to be even a Long Integer (32 bits), but it&#039s a perfectly valid integer when represented as a Double.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts