Author Topic: Off by a Wild One  (Read 1434 times)

Robert

  • Hero Member
  • *****
  • Posts: 1190
    • View Profile
Off by a Wild One
« on: December 02, 2020, 02:14:22 AM »
I got

Code: [Select]

 18446744073709551615
 18,446,744,073,709,551,616


Whadda you got?

 
Code: [Select]

 DIM RetValULL AS ULONGLONG
 DIM sBuf$
 
 RetValULL = Hx2DecULL("0xFFFFFFFFFFFFFFFF") ' 18446744073709551615
 
 sprintf(sBuf,"%llu",RetValULL)
 PRINT sBuf$

 PRINT USING$("###,###,###,###,###,###,###,###", RetValULL)
 
 PAUSE
 
 FUNCTION Hx2DecULL(h$) AS ULONGLONG
 
   DIM RAW hx$
   DIM RAW value AS ULONGLONG
 
   hx$ = LPAD$(REMAIN$(h$,"x"), 16, ASC("0"))
 
   value = ((ULONGLONG)HEX2DEC(LEFT$(hx$,8)) << 32)
   value|= (ULONG)HEX2DEC(RIGHT$(hx$,8))
 
   FUNCTION = value
 END FUNCTION


MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2039
    • View Profile
Re: Off by a Wild One
« Reply #1 on: December 02, 2020, 08:16:13 AM »

djsb

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Off by a Wild One
« Reply #2 on: March 25, 2023, 08:35:56 AM »
I get
Code: [Select]
18446744073709551615
18,446,744,073,709,551,245

Press any key to continue . . .


When compiling to a 64 bit exexcutable with PellesC V12
I wonder what could be happening this time?

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2039
    • View Profile
Re: Off by a Wild One
« Reply #3 on: March 25, 2023, 02:51:01 PM »
I wonder what could be happening this time?

Pelles C is obviously doing something different.

Mingw ( Equation Solution distro ) is the only compiler that I have that produces the correct output:

18446744073709551615
18,446,744,073,709,551,615

Press any key to continue . . .