Forum > Suggestions

wish list: ifthen, tothepowerof, BGRA components

(1/2) > >>

Blue1987:
i do not know if it is hte place where to write them, but I have a list of 3 features I would like to see 2 features implemented in fp and 1 in lazarus...

1a) a sintax like "ifthen(3>2,1,0)" as in delphi
1b) a function for "tothepowerof", something simple as "2^0.2" (every time I have to create a specific function for that)

2) the BGRA components included in the standard release of lazarus


:D



ludob:
Uses math;

function power(base,exponent : float) : float;

function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer; inline; overload;
function ifthen(val:boolean;const iftrue:int64  ; const iffalse:int64 = 0)  :int64;   inline; overload;
function ifthen(val:boolean;const iftrue:double ; const iffalse:double =0.0):double;  inline; overload;

Edit: forgot one

Uses strutils;

Function IfThen(AValue: Boolean; const ATrue: string; const AFalse: string = ''): string; overload;

IPguy:
re: PowerOf - I would like an integer version of this, but I get around the issue by creating a lookup table and using that.  I'm only using power of 2, so my needs are much easier to deal with than the general case.

Bart:

--- Quote from: IPguy on January 02, 2012, 03:30:16 pm ---re: PowerOf - I would like an integer version of this, but I get around the issue by creating a lookup table and using that.  I'm only using power of 2, so my needs are much easier to deal with than the general case.

--- End quote ---

If you need it only for integers:
If you mean 2 as exponent, in that case use sqr(),
or if you mean 2 as base, in that case you maybe can use shl operator (2^n = 1 shl n).

Bart

IPguy:
Bart,
thanks for the hints. 
I need it for base.  I'll try that suggestion.

Navigation

[0] Message Index

[#] Next page

Go to full version