What is 3.5f and how to initialize an array of udt

New to FreeBASIC? Post your questions here.
Post Reply
Sisophon2001
Posts: 1706
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

What is 3.5f and how to initialize an array of udt

Post by Sisophon2001 »

2 quick questions.

Hi:

1.
I saw in an OpenGL sample written by Victor that single precision numbers can have an optiona(?) f at the end of the number as in A = 3.5f.

Does this have any significance, or is it just ignored by the compiler?

2.
I would like to initialize an array of user defined type at compile time. I tried some syntax that looked like the syntax for initializing an array and gpf’ed the compiler.

Is this even possible? If not, then what is the most efficient way to initialize a mixed data type array. I understand data statements are all strings and must be converted at runtime.

type entry
a as integer
b AS byte ptr
c as double
end type

dim myentry(0 to 1) as entry =>{ _
{1,”try this”,2.3},
{2,”and this”,3.2}}

???

Thanks

Garvan
jofers
Posts: 1525
Joined: May 27, 2005 17:18

Post by jofers »

If it does has significance, it probably means that it casts the number as a signal-precision floating point (dim x as single).


Heh, if c suffixes ar in there I wonder if (type) casting is in there as well...
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

Yeah, the suffixes f, d, l, ll, ul, ull can be used, the case doesn't matter. The only important ones are the LL and ULL, when working with longint (64-bit) constants.

That type would only work if you did for example: {(strptr("abc", ...) ...}, but i found out that the compiler would crash if strptr was used in var-initializers with literal-strings, the fixes are in CVS..
Sisophon2001
Posts: 1706
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Post by Sisophon2001 »

It was strptr that caused the gpf but I was fishing for something that might work so I did not know if it should be supported.

Thanks

Garvan
Post Reply