Print bug?

New to FreeBASIC? Post your questions here.
ShawnLG
Posts: 137
Joined: Dec 25, 2008 20:21

Print bug?

Postby ShawnLG » May 09, 2020 17:22

Code: Select all

Print &hFFFFFFFF 'Prints a -1 in the terminal. The Print function cast it as an integer it should be cast as an Uinteger.
Josep Roca
Posts: 501
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: Print bug?

Postby Josep Roca » May 09, 2020 17:31

And how is going the compiler to know that you want it to be cast as UInteger if you don't tell it?

Use Print &hFFFFFFFFull

ull is the UInteger suffix.
grindstone
Posts: 752
Joined: May 05, 2015 5:35
Location: Germany

Re: Print bug?

Postby grindstone » May 09, 2020 17:48

ShawnLG wrote:

Code: Select all

Print &hFFFFFFFF 'Prints a -1 in the terminal. The Print function cast it as an integer it should be cast as an Uinteger.

I don't agree, because it would not be possible to print negative values.

Code: Select all

Print Cast(UInteger, -&hFFFFFFFF) 'Prints a 1
Josep Roca
Posts: 501
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: Print bug?

Postby Josep Roca » May 09, 2020 17:54

He wanted to print it as an UInteger.

Otherwise, you can do

Print -&hFFFFFFFF ' Prints 1
MrSwiss
Posts: 3613
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Print bug?

Postby MrSwiss » May 09, 2020 18:54

Josep Roca wrote:Use Print &hFFFFFFFFull ... ull is the UInteger suffix.
Nope, incorrect:
    ull (unsigned longlong (C-lang)) = ULongInt (in FB, 64 bit, fixed size)
    ui (unsigned long (C-lang)) = 32 or 64 bit UInteger (depending on Ptr size, aka: compilers bitness)
    ul (unsigned int (C-lang)) = ULong (in FB, 32 bit, fixed size)

Return to “Beginners”

Who is online

Users browsing this forum: St_W and 2 guests