Commit Graph

109 Commits

Author SHA1 Message Date
florian
53a4e6c513 * patch by Zoran Vučenović: fixes TDoubleRec.SetFrac, resolves #38202
+ test

git-svn-id: trunk@47765 -
2020-12-12 21:39:17 +00:00
pierre
e4e1ea586c Revert wrong change, llvm supports extended constants
git-svn-id: trunk@47554 -
2020-11-24 13:55:27 +00:00
pierre
6d900039c4 Fix LLVM compilation by casting untyped real constants to double type, as LLVM does not support extended type constant apparently
git-svn-id: trunk@47551 -
2020-11-24 08:02:29 +00:00
florian
7281ea7a2c * floating point division by zero should throw run time error 208, fixed
git-svn-id: trunk@46210 -
2020-08-03 19:42:16 +00:00
pierre
adf064cbb4 New: rtl/inc/genmathh.inc source file, to provide a unique position
for the interface definition of float64 and float32 records,
  available to all systems if FPUNONE is not defined.

  rtl/inc/genmath.inc: Remove float64/float32, as they are now in rtl/inc/genmathh.inc
  rtl/inc/softfpu.pp: Use provided definitions of float32 and float64
  if available (by checking presence of FPC_SYSTEM_HAS_floatXX macro)

  rtl/inc/systemh.inc: include genmathh.inc if FPUNONE is not defined.
  rtl/java/jsystemh_types.inc: Likewise.

git-svn-id: trunk@45821 -
2020-07-21 14:24:14 +00:00
pierre
834dbf5f80 Also use union with double field to ensure correct alignment for float64 type from genmath.inc source
git-svn-id: trunk@45779 -
2020-07-13 13:18:32 +00:00
florian
af1a4c06c5 * fixed generic round(...) for large values based on a comment by Alexander Hofmann on fpc-devel
* extended test

git-svn-id: trunk@44235 -
2020-02-23 10:41:18 +00:00
florian
c189af0e3d * improved software floating point exception handling in the rtl
git-svn-id: trunk@43163 -
2019-10-10 20:31:31 +00:00
florian
781ecf4a59 * modified patch by Bart Broersma to resolves #33932: fixes compilation error with FPC_SOFT_FPUX80 in TExtended80Rec.BuildUp
git-svn-id: trunk@39354 -
2018-07-01 12:54:30 +00:00
florian
2406bd052e * by default, TExtended80Rec.Mantissa should not return the hidden bit (the binary representation of the data type contains it always
git-svn-id: trunk@39348 -
2018-06-30 11:25:43 +00:00
michael
a9205c9fba * Fix bug ID #32837, correct Mantissa and Fraction in float helpers, patch from Bart Broersma
git-svn-id: trunk@39346 -
2018-06-29 20:51:32 +00:00
pierre
82dce8d7e1 Add FPC_SOFT_FPUX80 conditional code for 80-bit float type using soft float unit
git-svn-id: trunk@37294 -
2017-09-21 14:10:03 +00:00
sergei
feeb50be4f * Changed signature of frexp() to match one in Math unit, so eventually a duplicate implementation in Math can be removed. Currently this frexp() remains private to unit System.
git-svn-id: trunk@33173 -
2016-03-06 00:43:54 +00:00
sergei
92447a9a20 * Moved local typed constants having the same value in several routines to global scope.
git-svn-id: trunk@29207 -
2014-12-06 13:07:32 +00:00
nickysn
4fe1ec9c51 * fixed TSingleRec.SetSign on 16 and 8-bit CPUs
git-svn-id: trunk@29120 -
2014-11-23 14:14:03 +00:00
florian
7180d184c5 + implements TExtended80Rec, TDoubleRec, TSingleRec
+ test

git-svn-id: trunk@29084 -
2014-11-16 20:47:33 +00:00
sergei
6807812997 * Avoid promotion to 64 bits due to mixing signed and unsigned expressions.
git-svn-id: trunk@28510 -
2014-08-22 17:21:26 +00:00
sergei
f767d9017c * Fixed sin(-0.0) to return -0.0 (was returning 0.0)
* Fixed lnxp1(-1.0) to return -Inf (was returning NaN)

git-svn-id: trunk@27639 -
2014-04-23 10:03:18 +00:00
sergei
65f75791ea * rem_pio2: Return NaN for infinite or NaN arguments, so it is propagated into return values of sin(),cos() and other (not yet existing) callers.
git-svn-id: trunk@27625 -
2014-04-21 18:32:17 +00:00
sergei
57c762c8d2 + Inserted license header for AMath routines.
git-svn-id: trunk@27552 -
2014-04-12 20:45:44 +00:00
sergei
bd58adfcc9 + Added credits for functions reused from AMath/DAMath libraries.
git-svn-id: trunk@27518 -
2014-04-10 20:29:49 +00:00
sergei
217bac7a0b - Removed fpc_pi_real compilerproc, it is no longer used. At least two releases (2.6.2 and 2.6.4) emit Pi directly as a constant.
git-svn-id: trunk@27500 -
2014-04-07 09:16:24 +00:00
sergei
14ee9d52aa * Made constants DP1,DP2,DP3 local to function rem_pio2, because their values are correct only for double-precision calculations.
git-svn-id: trunk@27282 -
2014-03-25 14:32:14 +00:00
sergei
94a045aa3d * Moved declarations of TFPURoundingMode,TFPUExceptionMask and TFPUPrecisionMode to System unit. Declarations in Math unit changed to aliases.
* Changed type of softfloat_exception_mask and softfloat_exception_flags to TFPUExceptionMask, softfloat_rounding_mode to TFPURoundingMode.
- Cleaned out numerous conversions happening when getting/setting exception mask and rounding mode.

git-svn-id: trunk@27215 -
2014-03-20 22:44:46 +00:00
sergei
dcb46051c4 * Get rid of last softfloat dependencies in genmath.inc. Replaced remaining calls to float_raise with expressions which generate appropriate floating-point exceptions at runtime. This is probably somewhat slower on actual softfloat targets, but the change only affects exceptional control flow, so not a significant issue.
git-svn-id: trunk@27198 -
2014-03-20 11:04:00 +00:00
sergei
fffc317759 * Replaced fpc_round_real with new implementation, having the following important properties:
- it does not directly depend on softfloat stuff.
  - it triggers 'inexact' condition in a way compatible to hardware instructions (second assertion in webtbs/tw3157.pp now works correctly).

git-svn-id: trunk@27197 -
2014-03-20 05:33:33 +00:00
sergei
5f985602fb * Replaced fpc_ln_real with modern port from fdlibm/uclibc, it has even better accuracy than damath library.
git-svn-id: trunk@27172 -
2014-03-17 14:54:27 +00:00
sergei
aadb407e31 * Convert int64 to double in more straightforward way.
git-svn-id: trunk@26557 -
2014-01-21 14:33:56 +00:00
sergei
6dd845a183 * Removed TTabCoef type and unused zero members in coefficient arrays (the actual number of coefficients is passed to polevl/p1evl anyways).
* Use sizeint type instead of integer (the latter is 16-bit, resulting in unneeded adjustments on non-x86 targets).

git-svn-id: trunk@26556 -
2014-01-21 14:32:38 +00:00
Jonas Maebe
bf59a848b4 * fixed compilation of genmath.inc for the JVM target. In the future, please
use the new float64low/high() for getting the low/high longint and
    float64setlow/high() to set it

git-svn-id: trunk@26327 -
2013-12-30 14:30:59 +00:00
nickysn
779b92459e * fixed ldexp() on 16/8-bit CPUs. Among other things, this fixes sin() and cos()
on the i8086.

git-svn-id: trunk@26237 -
2013-12-15 23:08:23 +00:00
sergei
472b82c09a * Removed 'absolute'-style aliasing records to floating-point variables, because it causes internal compiler error on some targets.
git-svn-id: trunk@26122 -
2013-11-24 00:49:22 +00:00
sergei
b48ac658fb + Payne/Hanek argument reduction routine, improves accuracy of generic sin/cos functions over larger argument range. Tested on x86_64-win64 and mipsel-linux.
git-svn-id: trunk@26115 -
2013-11-20 22:20:47 +00:00
sergei
949b994a68 - Got rid of "goto".
git-svn-id: trunk@26104 -
2013-11-17 19:32:54 +00:00
sergei
4f0b3f61ec * fpc_trunc_real: explicitly cast float64.high and float32 to longint, fixes test suite regressions on softfloat targets. These targets have different definitions of float64/float32 (with unsigned fields), causing comparisons like "float64.high<0" to be optimized out.
git-svn-id: trunk@26095 -
2013-11-15 13:26:09 +00:00
sergei
897c8b8f7b * Cleanup fpc_trunc_real implementation.
* For single-precision variant, truncate to 64 bits instead of 32, since this how trunc()/round() are defined.
* Do not access float64 as int64, doing so would break on ARM hardfloat after r26010.
  

git-svn-id: trunk@26065 -
2013-11-12 09:31:23 +00:00
sergei
203efdcd0e * Let order of fields in float64 record depend on FPC_DOUBLE_HILO_SWAPPED, so messing with this order on every usage of float64 is no longer necessary.
git-svn-id: trunk@26010 -
2013-11-10 14:52:57 +00:00
sergei
d83fbd7602 * Replaced fpc_arctan_real() implementation with one providing a better precision.
git-svn-id: trunk@25994 -
2013-11-08 11:33:57 +00:00
sergei
441e37b8b4 - Eliminated separate extractFloat32* routines, they are used only once and manually inlining them does not harm to readability.
git-svn-id: trunk@25983 -
2013-11-07 10:12:13 +00:00
sergei
797653dd14 * Reverted overflow/underflow handling in fpc_exp_real to original state of C port. In particular, changed constant values to typed constants. Resolves #24839.
* Values like "huge" or "twom1000" must be declared as typed constants, so expressions using them are evaluated at runtime. E.g. "huge*huge" will either raise an overflow exception or will be evaluated as infinity, if overflows are masked. Calling float_raise() is not necessary anymore.
* Also replaced round() by trunc() when converting double to integer, this is how C defines such conversions.

git-svn-id: trunk@25945 -
2013-11-06 05:02:02 +00:00
sergei
690995fa12 * RTL: fixed some warnings when compiling for x86_64:
* x86_64/x86_64.inc: IsMultithread is a LongBool, not Boolean -> fixed assembler instruction suffixes
  * inc/generic.inc: cast Sizeof() to unsigned, so that combining it with unsigned operands does not cause promotion to larger signed type.
  + win64/seh64.inc: explicit typecast and missing function result assignment.
  + inc/genmath.inc: explicit typecasts.

git-svn-id: trunk@25384 -
2013-08-29 07:52:38 +00:00
florian
92477a14b8 o patch by Max Nazholov:
* more C code ported
 * missing exits fixed
 * var-modifier of shortShift128Left fixed
 * some range warnings fixed

git-svn-id: trunk@24871 -
2013-06-11 21:00:23 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
Jonas Maebe
e8dae4f30a * set result of exp() to 0 in case of underflow with masked exceptions
(mantis #21265)

git-svn-id: trunk@20368 -
2012-02-17 13:07:50 +00:00
sergei
2642403d5b * float_raise: Reduce amount of threadvar accesses, gains a bit more compact code. Functionality is not changed.
git-svn-id: trunk@19846 -
2011-12-13 20:21:22 +00:00
Jonas Maebe
8a95a04e16 * extracted dynarray helpers from system unit into jdynarr.inc (were
in the system unit for easier debugging)
  * disabled a bunch more feature flags by default for the JVM target
  * incorporate modified version of inc/systemh.inc (split into two parts:
    jsystemh_types.inc and jsystemh.inc, because some of the types are
    required for the declaration of the shortstring/ansistring/set/...
    classes, which in turn are required for the routine declarations) and
    inc/system.inc (as jsystem.inc)
   o moved some routines around from old to new locations based on where
     they appear in the common files
   o added a number of defines that allow skipping more common implementations
     in case a platform-specific one is already available
  * all base classes (AnsistringClass etc) are now descendants of
    JLObject rather than TObject, because their declaration is now parsed
    before TObject is known (and there's no need for them to inherit from
    TObject)
  * incorporate modified version of inc/system.inc
  * use the common version of generic.inc, currh.inc, gencurr.inc and
    genmath.inc (with small modification to those files)
  + addition of quite a bit of system unit functionality (halt, runerror,
    random, round, str() for integer types, abs, odd, endian swapping helpers,
    bit scanning, trigonometric functions, ln, exp, ...)
   o round()/trunc() for comp-types has been renamed trunc_comp() on the
     JVM target because their JVM signature conflicts with trunc(currency)
   o the unsigned versions of swapendian() and other endian helpers are not
     available on the JVM target because of JVM signature conflicts

git-svn-id: branches/jvmbackend@18746 -
2011-08-20 08:32:13 +00:00
Jonas Maebe
26cc281390 * fixed real48 to double conversion for 0.0 (patch by "jeng", mantis #16863)
git-svn-id: trunk@15543 -
2010-07-10 12:15:13 +00:00
Jonas Maebe
310ec39757 * fixed + optimized generic round_real
- removed cgenmath version of round_real because it wasn't any better
    than the generic one anymore

git-svn-id: trunk@11295 -
2008-06-28 14:17:06 +00:00
Jonas Maebe
30a51c2dee + support for the different rounding modes in the generic rounding
routines (mantis #11392)

git-svn-id: trunk@11290 -
2008-06-27 17:20:56 +00:00
florian
81fd66f6f6 * typo in define fixed
git-svn-id: trunk@11229 -
2008-06-15 10:54:26 +00:00