Recent

Author Topic: Where is the TSizeF type in the Types.pp  (Read 943 times)

dmitryb

  • Jr. Member
  • **
  • Posts: 69
Where is the TSizeF type in the Types.pp
« on: August 13, 2024, 08:57:07 pm »
I'm wondering why there is a type declaration in the Types.pp file:
TSize, TPoint, TRect
TPointF, TRectF

But there is no TSizeF type.
Is it declared in some other file?
I didn't find where.

Thaddy

  • Hero Member
  • *****
  • Posts: 15646
  • Censorship about opinions does not belong here.
Re: Where is the TSizeF type in the Types.pp
« Reply #1 on: August 13, 2024, 09:03:05 pm »
Why would you expect that? a type has a fixed size expressed in one of the integer types. types are not size 1.0000345678 size.
If I smell bad code it usually is bad code and that includes my own code.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5672
  • Compiler Developer
Re: Where is the TSizeF type in the Types.pp
« Reply #2 on: August 13, 2024, 09:20:17 pm »
But there is no TSizeF type.
Is it declared in some other file?

There will be a Types.TSizeF in the upcoming FPC 3.2.4.

Why would you expect that? a type has a fixed size expressed in one of the integer types. types are not size 1.0000345678 size.

Why wouldn't there be a floating point size? After all a floating point rectangle can start at e.g. (1/2), but end at (2.3/2.4) which would make its size (1.3/0.4). It's simply a logical extension of what TRectF provides.

dmitryb

  • Jr. Member
  • **
  • Posts: 69
Re: Where is the TSizeF type in the Types.pp
« Reply #3 on: August 13, 2024, 09:21:16 pm »
For example.
In a graphical resizing animation, the animation looks smoother if it is drawn based on more precise floating point values ​​at intermediate points than based on integer values.

Khrys

  • Jr. Member
  • **
  • Posts: 91
Re: Where is the TSizeF type in the Types.pp
« Reply #4 on: August 14, 2024, 07:08:29 am »
I think Thaddy simply mistook "a type called  TSizeF" for "a type with a floating-point size"SizeOf  will of course always return an integer - for very fundamental reasons that every programmer should know. Personally I've never seen any who struggle with this, but I've seen plenty who might want to work on their reading skills   :)

TRon

  • Hero Member
  • *****
  • Posts: 3236
Re: Where is the TSizeF type in the Types.pp
« Reply #5 on: August 14, 2024, 07:15:43 am »
Thanks to dmitryb for asking the question because I wondered about that myself as well.

There will be a Types.TSizeF in the upcoming FPC 3.2.4.
Thank you very much.

Now I can finally get rid of my own half-baked definition (well, whenever 3.2.4 is released that is) :-)
All software is open source (as long as you can read assembler)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5672
  • Compiler Developer
Re: Where is the TSizeF type in the Types.pp
« Reply #6 on: August 15, 2024, 07:53:28 pm »
I think Thaddy simply mistook "a type called  TSizeF" for "a type with a floating-point size".

Thaddy mistaking things is his usually modus operandi after all... 😅

Thaddy

  • Hero Member
  • *****
  • Posts: 15646
  • Censorship about opinions does not belong here.
Re: Where is the TSizeF type in the Types.pp
« Reply #7 on: August 15, 2024, 09:36:49 pm »
Yes, but not always..... :D
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018