I already added support for my needs, which wouldn't be of use to others; I have special rules. Divide by zero isn't an error. I'm only interested in a few things.
Requires compiling a DLL.
The lib is "mpfr.h." Used by; Julia, R, SageMath, GCC, GFortran, Python, C++, Rust, Go, Java, Fortran, Haskell.
You could add it if you wish. This is an extremely confusing topic because GCC and Clang have different target versions. Clang used by Tiko doesn't support it. I also have MSYS2 MinGW-w64 ucrt64 GCC installed.
The solution is simple. Tell AI what you want to do and ask it what it needs to do it.
That's what I did but the answer was confusing, there are tool chain conflicts.
I gave DeepSeek this prompt, done deal.
folder: C:\tiko-code\F256
install what's needed and build the dll and write F256.ti include file.
I have a lot of link info in the prompt.
new programming compiler: Tiko
PDF: the-tiko-programming-language.pdf
compiler and include files: C:\tiko-lang
wiki: https://github.com/PaulSquires/tiko-lang/wiki
github: https://github.com/PaulSquires/tiko-lang/
My needs are simple, but you'd have to decide how and what to implement. Whole lot of stuff in there. AI, "what math does gcc mpfr.h support."
It built one inc for DLL and another for implementation. It only added support for what I asked for, but the DLL should support whatever you want to support.
F256.ti
PASSED: 172, FAILED: 0 edge test.
'' =============================================================================
'' F256.ti -- owning Tiko type for f256.dll
''
'' Include this once in the module that uses it:
''
'' #include once "C:/tiko-code/F256/F256.ti"
''
'' dim a as F256 = F256( "1.25" )
'' dim b as F256 = F256( "2.5" )
'' print a + b
''
'' The destructor calls tiko_f256_free, which calls mpfr_clear.
'' Call F256Finalize( ) once at program exit for mpfr_free_cache( ).
'' =============================================================================
#include once "F256_DLL.ti"
'' F256Finalize -- call once, after the last F256 value has been destroyed.
''
'' The F256 destructor already calls tiko_f256_free, which calls mpfr_clear
'' for that number. F256Finalize is a different, process-wide cleanup: it
'' calls mpfr_free_cache, releasing MPFR's internal cached constants and
'' tables -- not the mpfr_t values owned by F256 objects.
''
'' When to call:
'' - once at the end of the program, after all F256 objects are out of
'' scope or have been freed;
'' - before leak checking or final accounting that should see MPFR's
'' caches released.
''
'' When not to call:
'' - after every number; the destructors already do per-number cleanup;
'' - while F256 values are still alive and will be used again.
''
'' Process exit would reclaim the memory anyway. Calling this makes the
'' cleanup explicit and deterministic. MPFR rebuilds its cache on demand,
'' so a later call is not fatal, but calling it once after the final use
'' is the intended pattern.
sub F256Finalize( )
tiko_f256_final( )
end sub
type F256
h as uint64
declare constructor( )
declare constructor( byref value as const ustring )
declare constructor( byref other as const F256 )
declare operator let( byref other as const F256 )
declare destructor( )
declare operator cast( ) as ustring
declare function ToStr( ) as ustring
declare function IsValid( ) as boolean
declare sub SetStr( byref value as const ustring )
declare sub SetI32( byval value as int32 )
declare sub SetU32( byval value as uint32 )
declare sub SetF64( byval value as float64 )
declare operator += ( byref other as const F256 )
declare operator -= ( byref other as const F256 )
declare operator *= ( byref other as const F256 )
declare operator /= ( byref other as const F256 )
end type
constructor F256( )
h = tiko_f256_new( "0" )
end constructor
constructor F256( byref value as const ustring )
h = tiko_f256_new( value )
end constructor
constructor F256( byref other as const F256 )
h = tiko_f256_clone( other.h )
end constructor
operator F256.let( byref other as const F256 )
if @this = @other then exit operator
tiko_f256_free( h )
h = tiko_f256_clone( other.h )
end operator
destructor F256( )
tiko_f256_free( h )
h = 0
end destructor
operator F256.cast( ) as ustring
return *tiko_f256_to_str( h )
end operator
function F256.ToStr( ) as ustring
return *tiko_f256_to_str( h )
end function
function F256.IsValid( ) as boolean
return tiko_f256_valid( h ) <> 0
end function
sub F256.SetStr( byref value as const ustring )
tiko_f256_from_str( h, value )
end sub
sub F256.SetI32( byval value as int32 )
tiko_f256_set_i32( h, value )
end sub
sub F256.SetU32( byval value as uint32 )
tiko_f256_set_u32( h, value )
end sub
sub F256.SetF64( byval value as float64 )
tiko_f256_set_f64( h, value )
end sub
operator F256.+= ( byref other as const F256 )
tiko_f256_add( h, h, other.h )
end operator
operator F256.-= ( byref other as const F256 )
tiko_f256_sub( h, h, other.h )
end operator
operator F256.*= ( byref other as const F256 )
tiko_f256_mul( h, h, other.h )
end operator
operator F256./= ( byref other as const F256 )
if tiko_f256_is_zero( other.h ) <> 0 then
tiko_f256_set_u32( h, 0 )
exit operator
end if
tiko_f256_div( h, h, other.h )
end operator
declare operator + ( byref a as const F256, byref b as const F256 ) as F256
declare operator - ( byref a as const F256, byref b as const F256 ) as F256
declare operator * ( byref a as const F256, byref b as const F256 ) as F256
declare operator / ( byref a as const F256, byref b as const F256 ) as F256
operator + ( byref a as const F256, byref b as const F256 ) as F256
dim r as F256
tiko_f256_add( r.h, a.h, b.h )
return r
end operator
operator - ( byref a as const F256, byref b as const F256 ) as F256
dim r as F256
tiko_f256_sub( r.h, a.h, b.h )
return r
end operator
operator * ( byref a as const F256, byref b as const F256 ) as F256
dim r as F256
tiko_f256_mul( r.h, a.h, b.h )
return r
end operator
operator / ( byref a as const F256, byref b as const F256 ) as F256
dim r as F256
if tiko_f256_is_zero( b.h ) <> 0 then
return r
end if
tiko_f256_div( r.h, a.h, b.h )
return r
end operator
sub Squared( byref result as F256, byref other as const F256 )
' result = other squared
' result = 0 if other = 0, not negative 0
' result = absolute result
if tiko_f256_is_zero( other.h ) <> 0 then
tiko_f256_set_u32( result.h, 0 )
return
end if
tiko_f256_squared( result.h, other.h )
tiko_f256_abs( result.h, result.h )
end sub
sub SquareRoot( byref result as F256, byref other as const F256 )
' result = square root of other
' result = 0 if other = 0, not negative 0
' result = absolute result
if tiko_f256_is_zero( other.h ) <> 0 then
tiko_f256_set_u32( result.h, 0 )
return
end if
tiko_f256_sqrt( result.h, other.h )
tiko_f256_abs( result.h, result.h )
end sub
sub Cubed( byref result as F256, byref other as const F256 )
' result = other cubed
' result = 0 if other = 0, not negative 0
' result = absolute result
if tiko_f256_is_zero( other.h ) <> 0 then
tiko_f256_set_u32( result.h, 0 )
return
end if
tiko_f256_cubed( result.h, other.h )
tiko_f256_abs( result.h, result.h )
end sub
sub CubeRoot( byref result as F256, byref other as const F256 )
' result = cube root of other
' result = 0 if other = 0, not negative 0
' result = absolute result
if tiko_f256_is_zero( other.h ) <> 0 then
tiko_f256_set_u32( result.h, 0 )
return
end if
tiko_f256_cbrt( result.h, other.h )
tiko_f256_abs( result.h, result.h )
end sub
sub Absolute( byref result as F256, byref other as const F256 )
' result = absolute other
tiko_f256_abs( result.h, other.h )
end sub
sub Copy( byref result as F256, byref other as const F256 )
' result = copy of other
tiko_f256_copy( result.h, other.h )
end sub
Cool stuff! This is an topic area that I haven't had a need to use over the years. Floating point types of that degree do seem like a very niche need but I'm sure there are users out there that love these types of data types. 8)
256-bit floating point is mandatory for science. One of those things you don't need until you need it, then you may be in trouble.
Trying to support the whole thing might be more complex than the compiler; https://www.mpfr.org/mpfr-current/mpfr.html.
That's why I just made a simple wrapper around what I needed.
I forgot the "=" operator which I had DS add. Combined the two include files into one. Copy INC and DLL to source and you're good to go.
You have to pass it down unless you allocate a ptr.
Other than that, because of the operators, there's almost no difference in use.
Trying to use any other implementation is a whole new programming language.
One of those things to put on the back burner. Maybe implement some things at some point. No request, no need. But I do see that some FB and PB uses did have a need. They implemented something to solve it.