J
jacob navia
The Find First Set function (ffs) finds the lowest bit set in an
integer.
I wanted to add this to the library in lcc-win but before doing it I
would like your opinion as to *where* should I declare them?
First, this function is POSIX and the include file is called
"strings.h"
I do not know why. There you will find bzero() and other functions
that have absolutely nothing to do with any strings. The only
string functions there are strcasecmp (that is equivalent to
stricmp in lcc-win) and strncasecmp (equivalent to strnicmp).
Question:
Should I add a "utils.h" header?
Or follow POSIX?
I have a founction for counting bits in an integer and I
have added it in bitstring.h but that is a header concerned
with the bit string implementation... Not really the subject
of those functions.
Since I am revising this, I added the function
fls (Find Last Set) that will find the higher order
bit in an integer. Strange, this function is NOT in POSIX. Maybe
anyone here knows why?
Below is the documentation for both functions
--------------------------------------------------------------------
Function: _ffs _fls
Synopsis
#include <utils.h> // ???????????????????
int _stdcall _ffs(int n);
int _stdcall _fls(int n);
Description
The fsf() function returns the index of the first bit different from
zero in the given integer argument. The first bit (the least
significant) is numbered 1.
The fls() function returns the index of the first most significant bit
set.. Bit indexes start at 1.
Returns
The value of the index or zero if and only if all bits are zero
;
integer.
I wanted to add this to the library in lcc-win but before doing it I
would like your opinion as to *where* should I declare them?
First, this function is POSIX and the include file is called
"strings.h"
I do not know why. There you will find bzero() and other functions
that have absolutely nothing to do with any strings. The only
string functions there are strcasecmp (that is equivalent to
stricmp in lcc-win) and strncasecmp (equivalent to strnicmp).
Question:
Should I add a "utils.h" header?
Or follow POSIX?
I have a founction for counting bits in an integer and I
have added it in bitstring.h but that is a header concerned
with the bit string implementation... Not really the subject
of those functions.
Since I am revising this, I added the function
fls (Find Last Set) that will find the higher order
bit in an integer. Strange, this function is NOT in POSIX. Maybe
anyone here knows why?
Below is the documentation for both functions
--------------------------------------------------------------------
Function: _ffs _fls
Synopsis
#include <utils.h> // ???????????????????
int _stdcall _ffs(int n);
int _stdcall _fls(int n);
Description
The fsf() function returns the index of the first bit different from
zero in the given integer argument. The first bit (the least
significant) is numbered 1.
The fls() function returns the index of the first most significant bit
set.. Bit indexes start at 1.
Returns
The value of the index or zero if and only if all bits are zero
;