jacob navia said:
The regulars said that speaking about 128 bit integers is off topic
since the code doesn't run under gcc, it is specific to lcc-win etc.
They have no clue actually. Gcc supports in some platforms 128 bit
integers. The syntax they use is:
int __attribute__((__mode__(__TI__))
unsignd int __attribute__((__mode__(__TI__))
yep, gcc and its usual horrid extension syntax...
References:
http://gcc.gnu.org/ml/gcc/2000-09/msg00419.html
Now that gcc supports them, (and not only lcc-win)
this will be accepted here I hope...
probably not, since in the minds of the people here, this would mean
elevating gcc'isms to the level of the standard...
I use the syntax __int128 and __uint128 personally...
in my compiler, they are also supported by a modified 'inttypes.h', which
defines int128_t and uint128_t (at least for my compiler).
it is worth noting that MSVC does not have this header.
however, for use with good old static compilers (gcc, MSVC, ...) I have
ended up using a struct-based representation.
I remember seeing somewhere that MSVC adds int128, but only for C++ (it is
implemented as a class with operator overloading...). their implementation
is partially based on SIMD intrinsics.
recently, I have ended up adding my own complexes, mostly as MSVC does not
support C99 style complexes (my compiler supports them, however).
I have implemented them mostly with structs.
fcomplex a, b, c, d;
a=fcomplex(1,0);
b=fcomplex(0,1);
c=fcadd(a, b);
d=fcmul(a, b);
there is also dcomplex, and similar 'dc' functions.
my current vector and quat code should also work on gcc and MSVC, but is
currently only "vectorized" for MSVC (since MSVC and GCC don't strictly use
the same vector facilities).
even as such, operations like 'qpow', 'qsin', 'qcos', ... are likely to be
rather slow, although I have not yet benchmarked them (or even verified that
they work...).
as for 'qsin', 'qcos', 'qtan', ... I have implemented these operations (as
per conventional definitions), although I don't know exactly just what they
are supposed to do (and am largely unable to 'visualize' these
operations...).
(my mind seems to partially handle this by using multiple concurrent
'projections' of the space, but this would be further complicated if I were
to plot graphically, since my internal mental projections tend to be full 3D
I think, rather than 2D projections, so I am not the "best" way to project
4D into 2D plots/graphs...).
I could add a "raw" int128 and float128 APIs to C via similar mechanisms,
just it is a question of prefixes.
'dqi' and 'dqf' are possible (slightly less awkward to type than 'i128' and
'f128'...).
dqi128 a, b;
a=dqi128("6942031415926535897932384");
//above: because a string is the only really typable representation I know
of...
b=dqimul(a, a);
....
'dqf' would be about the same, but floating point...
as before, these would probably be good old structs, and probably plain old
C.
(if really needed, I could assembler optimize these though...).
among many other things...