MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / xsum_add1_no_carry

Function xsum_add1_no_carry

xs/sources/xsum.c:854–981  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

852 procedure call overhead will result in substantial inefficiency). */
853
854static INLINE void xsum_add1_no_carry (xsum_small_accumulator *restrict sacc,
855 xsum_flt value)
856{
857 xsum_int ivalue;
858 xsum_int mantissa;
859 xsum_expint exp, low_exp, high_exp;
860 xsum_schunk *chunk_ptr;
861
862 if (xsum_debug)
863 { c_printf ("ADD1 %+.17le\n ", (double) value);
864 pbinary_double ((double) value);
865 c_printf("\n");
866 }
867
868 /* Extract exponent and mantissa. Split exponent into high and low parts. */
869
870 COPY64 (ivalue, value);
871
872 exp = (ivalue >> XSUM_MANTISSA_BITS) & XSUM_EXP_MASK;
873 mantissa = ivalue & XSUM_MANTISSA_MASK;
874 high_exp = exp >> XSUM_LOW_EXP_BITS;
875 low_exp = exp & XSUM_LOW_EXP_MASK;
876
877 if (xsum_debug)
878 { c_printf(" high exp: ");
879 pbinary_int64 (high_exp, XSUM_HIGH_EXP_BITS);
880 c_printf(" low exp: ");
881 pbinary_int64 (low_exp, XSUM_LOW_EXP_BITS);
882 c_printf("\n");
883 }
884
885 /* Categorize number as normal, denormalized, or Inf/NaN according to
886 the value of the exponent field. */
887
888 if (exp == 0) /* zero or denormalized */
889 { /* If it's a zero (positive or negative), we do nothing. */
890 if (mantissa == 0)
891 { return;
892 }
893 /* Denormalized mantissa has no implicit 1, but exponent is 1 not 0. */
894 exp = low_exp = 1;
895 }
896 else if (exp == XSUM_EXP_MASK) /* Inf or NaN */
897 { /* Just update flags in accumulator structure. */
898 xsum_small_add_inf_nan (sacc, ivalue);
899 return;
900 }
901 else /* normalized */
902 { /* OR in implicit 1 bit at top of mantissa */
903 mantissa |= (xsum_int)1 << XSUM_MANTISSA_BITS;
904 }
905
906 if (xsum_debug)
907 { c_printf(" mantissa: ");
908 pbinary_int64 (mantissa, XSUM_MANTISSA_BITS+1);
909 c_printf("\n");
910 }
911

Callers 4

xsum_small_add1Function · 0.85
xsum_small_addvFunction · 0.85
xsum_small_add_sqnormFunction · 0.85
xsum_small_add_dotFunction · 0.85

Calls 1

xsum_small_add_inf_nanFunction · 0.85

Tested by

no test coverage detected