Page 1 of 1

decNumber pbi

Posted: Sun Feb 12, 2017 12:36 pm
by jack
here are the decNumber header translations http://speleotrove.com/decimal/decnumber.html
you need to correct the path and lib name in ImportC "/usr/local/lib/libdecnumber.a"
also, depending on how your C compiler mangles the symbols you may need to add or remove underscores in the imports.

compiling using VC, you need to correct the path and version
for 32-bit
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
cl /MD /O2 /c /GS- decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
lib /OUT:libdecNumber.lib *.obj

for 64-bit
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
cl /MD /O2 /c /GS- decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
lib /OUT:libdecNumber.lib *.obj

compiling using gcc
gcc -c -O2 decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
ar rcs libdecnumber.a *.o

decContext.pbi

Code: Select all

;/* ------------------------------------------------------------------ */
;/* Decimal Context module header                                      */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
;/*                                                                    */
;/* This software is made available under the terms of the             */
;/* ICU License -- ICU 1.8.1 and later.                                */
;/*                                                                    */
;/* The description and User's Guide ("The decNumber C Library") for   */
;/* this software is called decNumber.pdf.  This document is           */
;/* available, together with arithmetic and format specifications,     */
;/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
;/*                                                                    */
;/* Please send comments, suggestions, and corrections to the author:  */
;/*   mfc@uk.ibm.com                                                   */
;/*   Mike Cowlishaw, IBM Fellow                                       */
;/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
;/* ------------------------------------------------------------------ */
;/*                                                                    */
;/* Context variables must always have valid values:                   */
;/*                                                                    */
;/*  status   -- [any bits may be cleared, but not set, by user]       */
;/*  round    -- must be one of the Enumerationerated rounding modes          */
;/*                                                                    */
;/* The following variables are implied for fixed size formats (i.e.,  */
;/* they are ignored) but should still be set correctly in case used   */
;/* with decNumber functions:                                          */
;/*                                                                    */
;/*  clamp    -- must be either 0 or 1                                 */
;/*  digits   -- must be in the range 1 through 999999999              */
;/*  emax     -- must be in the range 0 through 999999999              */
;/*  emin     -- must be in the range 0 through -999999999             */
;/*  extended -- must be either 0 or 1 [present only if DECSUBSET]     */
;/*  traps    -- only defined bits may be set                          */
;/*                                                                    */
;/* ------------------------------------------------------------------ */
CompilerIf Defined(DECCONTEXT,#PB_Constant)=0
  #DECCONTEXT =  1
  #DECCNAME   =  "decContext"                     ;/* Short name */
  #DECCFULLNAME = "Decimal Context Descriptor"   ;/* Verbose name */
  #DECCAUTHOR   = "Mike Cowlishaw"               ;/* Who to blame */

  Macro int8_t
    b
  EndMacro
  Macro uint8_t
    b
  EndMacro
  Macro int16_t
    w
  EndMacro
  Macro uint16_t
    w
  EndMacro
  Macro int32_t
    l
  EndMacro
  Macro uint32_t
    l
  EndMacro
  Macro int64_t
    q
  EndMacro
  Macro uint64_t
    q
  EndMacro
  
  #DECUSE64 = 1 ;defined in decNumberLocal.h
  
  ;/* Extended flags setting -- set this to 0 to use only IEEE flags   */
  CompilerIf Defined(DECEXTFLAG,#PB_Constant)=0
  	#DECEXTFLAG = 1             ;/* 1=enable extended flags         */
  CompilerEndIf

  ;/* Conditional code flag -- set this to 0 for best performance      */
  CompilerIf Defined(DECSUBSET,#PB_Constant)=0
  	#DECSUBSET = 0             ;/* 1=enable subset arithmetic      */
  CompilerEndIf

  ;/* Context for operations, with associated constants                */
  Enumeration ;rounding
    #DEC_ROUND_CEILING             ;/* round towards +infinity         */
    #DEC_ROUND_UP                  ;/* round away from 0               */
    #DEC_ROUND_HALF_UP             ;/* 0.5 rounds up                   */
    #DEC_ROUND_HALF_EVEN           ;/* 0.5 rounds to nearest even      */
    #DEC_ROUND_HALF_DOWN           ;/* 0.5 rounds down                 */
    #DEC_ROUND_DOWN                ;/* round towards 0 (truncate)      */
    #DEC_ROUND_FLOOR               ;/* round towards -infinity         */
    #DEC_ROUND_05UP                ;/* round for reround               */
    #DEC_ROUND_MAX                 ;/* Enumeration must be less than this     */
  EndEnumeration

  #DEC_ROUND_DEFAULT = #DEC_ROUND_HALF_EVEN

  Structure decContext
    digits.int32_t               ;/* working precision               */
    emax.int32_t                 ;/* maximum positive exponent       */
    emin.int32_t                 ;/* minimum negative exponent       */
    rounding.l                   ;/* rounding mode                   */
    traps.uint32_t               ;/* trap-enabler flags              */
    Status.uint32_t              ;/* status flags                    */
    clamp.uint8_t                ;/* flag: apply IEEE exponent clamp */
    CompilerIf #DECSUBSET
    	extended.uint8_t         ;/* flag: special-values allowed    */
    CompilerEndIf
  EndStructure

  ;/* Maxima and Minima for context settings                           */
  #DEC_MAX_DIGITS =  999999999
  #DEC_MIN_DIGITS =          1
  #DEC_MAX_EMAX   =  999999999
  #DEC_MIN_EMAX   =          0
  #DEC_MAX_EMIN   =          0
  #DEC_MIN_EMIN   = -999999999
  #DEC_MAX_MATH   =     999999 ;/* max emax, etc., for math funcs. */

  ;/* Classifications for decimal numbers, aligned with 754r (note     */
  ;/* that 'normal' and 'subnormal' are meaningful only with a         */
  ;/* decContext or a fixed size format).                              */
  Enumeration ;decClass
    #DEC_CLASS_SNAN
    #DEC_CLASS_QNAN
    #DEC_CLASS_NEG_INF
    #DEC_CLASS_NEG_NORMAL
    #DEC_CLASS_NEG_SUBNORMAL
    #DEC_CLASS_NEG_ZERO
    #DEC_CLASS_POS_ZERO
    #DEC_CLASS_POS_SUBNORMAL
    #DEC_CLASS_POS_NORMAL
    #DEC_CLASS_POS_INF
  EndEnumeration
  ;/* Strings for the decClasses */
  #DEC_ClassString_SN  = "sNaN"
  #DEC_ClassString_QN  = "NaN"
  #DEC_ClassString_NI  = "-Infinity"
  #DEC_ClassString_NN  = "-Normal"
  #DEC_ClassString_NS  = "-Subnormal"
  #DEC_ClassString_NZ  = "-Zero"
  #DEC_ClassString_PZ  = "+Zero"
  #DEC_ClassString_PS  = "+Subnormal"
  #DEC_ClassString_PN  = "+Normal"
  #DEC_ClassString_PI  = "+Infinity"
  #DEC_ClassString_UN  = "Invalid"

  ;/* Trap-enabler and Status flags (exceptional conditions), and      */
  ;/* their names.  The top byte is reserved for internal use          */
  CompilerIf #DECEXTFLAG
    ;/* Extended flags */
    #DEC_Conversion_syntax    = $00000001
    #DEC_Division_by_zero     = $00000002
    #DEC_Division_impossible  = $00000004
    #DEC_Division_undefined   = $00000008
    #DEC_Insufficient_storage = $00000010 ;/* [when malloc fails]  */
    #DEC_Inexact              = $00000020
    #DEC_Invalid_context      = $00000040
    #DEC_Invalid_operation    = $00000080
    CompilerIf #DECSUBSET
      #DEC_Lost_digits        = $00000100
    CompilerEndIf
    #DEC_Overflow             = $00000200
    #DEC_Clamped              = $00000400
    #DEC_Rounded              = $00000800
    #DEC_Subnormal            = $00001000
    #DEC_Underflow            = $00002000
  CompilerElse
    ;/* IEEE flags only */
    #DEC_Conversion_syntax    = $00000010
    #DEC_Division_by_zero     = $00000002
    #DEC_Division_impossible  = $00000010
    #DEC_Division_undefined   = $00000010
    #DEC_Insufficient_storage = $00000010 ;/* [when malloc fails]  */
    #DEC_Inexact              = $00000001
    #DEC_Invalid_context      = $00000010
    #DEC_Invalid_operation    = $00000010
    CompilerIf #DECSUBSET
      #DEC_Lost_digits        = $00000000
    CompilerEndIf
    #DEC_Overflow             = $00000008
    #DEC_Clamped              = $00000000
    #DEC_Rounded              = $00000000
    #DEC_Subnormal            = $00000000
    #DEC_Underflow            = $00000004
  CompilerEndIf

  ;/* IEEE 854 groupings for the flags                                 */
  ;/* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal    */
  ;/* are not in IEEE 854]                                             */
  #DEC_IEEE_854_Division_by_zero  =(#DEC_Division_by_zero)
  CompilerIf #DECSUBSET
  	#DEC_IEEE_854_Inexact     =(#DEC_Inexact | #DEC_Lost_digits)
  CompilerElse
  	#DEC_IEEE_854_Inexact     =(#DEC_Inexact)
  CompilerEndIf
  #DEC_IEEE_854_Invalid_operation =(#DEC_Conversion_syntax | #DEC_Division_impossible | #DEC_Division_undefined | #DEC_Insufficient_storage | #DEC_Invalid_context | #DEC_Invalid_operation)
  #DEC_IEEE_854_Overflow          =(#DEC_Overflow)
  #DEC_IEEE_854_Underflow         =(#DEC_Underflow)

  ;/* flags which are normally errors (result is qNaN, infinite, or 0) */
  #DEC_Errors =(#DEC_IEEE_854_Division_by_zero | #DEC_IEEE_854_Invalid_operation | #DEC_IEEE_854_Overflow | #DEC_IEEE_854_Underflow)
  ;/* flags which cause a result to become qNaN                        */
  #DEC_NaNs    =#DEC_IEEE_854_Invalid_operation

  ;/* flags which are normally for information only (finite results)   */
  CompilerIf #DECSUBSET
  	#DEC_Information =(#DEC_Clamped | #DEC_Rounded | #DEC_Inexact | #DEC_Lost_digits)
  CompilerElse
  	#DEC_Information =(#DEC_Clamped | #DEC_Rounded | #DEC_Inexact)
  CompilerEndIf

  ;/* Name strings for the exceptional conditions                      */
  #DEC_Condition_CS = "Conversion syntax"
  #DEC_Condition_DZ = "Division by zero"
  #DEC_Condition_DI = "Division impossible"
  #DEC_Condition_DU = "Division undefined"
  #DEC_Condition_IE = "Inexact"
  #DEC_Condition_IS = "Insufficient storage"
  #DEC_Condition_IC = "Invalid context"
  #DEC_Condition_IO = "Invalid operation"
  CompilerIf #DECSUBSET
  	#DEC_Condition_LD = "Lost digits"
  CompilerEndIf
  #DEC_Condition_OV = "Overflow"
  #DEC_Condition_PA = "Clamped"
  #DEC_Condition_RO = "Rounded"
  #DEC_Condition_SU = "Subnormal"
  #DEC_Condition_UN = "Underflow"
  #DEC_Condition_ZE = "No status"
  #DEC_Condition_MU = "Multiple status"
  #DEC_Condition_Length = 21  ;/* length of the longest string,   */
                                   ;/* including terminator            */

  ;/* Initialization descriptors, used by decContextDefault            */
  #DEC_INIT_BASE       =   0
  #DEC_INIT_DECIMAL32  =  32
  #DEC_INIT_DECIMAL64  =  64
  #DEC_INIT_DECIMAL128 = 128
  ;/* Synonyms */
  #DEC_INIT_DECSINGLE  = #DEC_INIT_DECIMAL32
  #DEC_INIT_DECDOUBLE  = #DEC_INIT_DECIMAL64
  #DEC_INIT_DECQUAD    = #DEC_INIT_DECIMAL128
  
  
  ;/* decContext routines   */
  ImportC "/usr/local/lib/libdecnumber.a"
    decContextClearStatus(*a.decContext, b.uint32_t);decContext  * 
    decContextDefault(*a.decContext , b.int32_t); As "_decContextDefault";decContext  * 
    decContextGetRounding(*a.decContext);enum rounding 
    decContextGetStatus(*a.decContext);uint32_t 
    decContextRestoreStatus(*a.decContext , b.uint32_t, c.uint32_t);decContext  * 
    decContextSaveStatus(*a.decContext , b.uint32_t);uint32_t      
    decContextSetRounding(*a.decContext , rounding.l);decContext  * 
    decContextSetStatus(*a.decContext , b.uint32_t);decContext  * 
    decContextSetStatusFromString(*a.decContext , s.s);decContext  * 
    decContextSetStatusFromStringQuiet(*a.decContext , s.s);decContext  * 
    decContextSetStatusQuiet(*a.decContext , b.uint32_t);decContext  * 
    decContextStatusToString(*a.decContext);const char  * 
    decContextTestEndian(a.uint8_t);int32_t       
    decContextTestSavedStatus(a.uint32_t, b.uint32_t);uint32_t      
    decContextTestStatus(*a.decContext , b.uint32_t);uint32_t      
    decContextZeroStatus(*a.decContext);decContext  * 
  EndImport

CompilerEndIf      

Re: decNumber pbi

Posted: Sun Feb 12, 2017 12:39 pm
by jack
decDouble.pbi

Code: Select all

;/* ------------------------------------------------------------------ */
;/* decDouble.h -- Decimal 64-bit format module header                 */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
;/*                                                                    */
;/* This software is made available under the terms of the             */
;/* ICU License -- ICU 1.8.1 and later.                                */
;/*                                                                    */
;/* Please send comments, suggestions, and corrections to the author:  */
;/*   mfc@uk.ibm.com  (Mike Cowlishaw FREng, IBM Fellow,               */
;/*   IBM UK MP8, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK     */
;/* ------------------------------------------------------------------ */

CompilerIf Defined(DECDOUBLE, #PB_Constant)=0
  #DECDOUBLE          = 1

  #DECDOUBLENAME      = "decimalDouble"         ;/* Short name   */
  #DECDOUBLETITLE     = "Decimal 64-bit datum"  ;/* Verbose name */
  #DECDOUBLEAUTHOR    = "Mike Cowlishaw"        ;/* Who to blame */

  ;/* parameters for decDoubles */
  #DECDOUBLE_Bytes   = 8      ;/* length                          */
  #DECDOUBLE_Pmax    = 16     ;/* maximum precision (digits)      */
  #DECDOUBLE_Emin    =-383    ;/* minimum adjusted exponent       */
  #DECDOUBLE_Emax    = 384    ;/* maximum adjusted exponent       */
  #DECDOUBLE_EmaxD   = 3      ;/* maximum exponent digits         */
  #DECDOUBLE_Bias    = 398    ;/* bias for the exponent           */
  #DECDOUBLE_String  = 25     ;/* maximum string length, +1       */
  #DECDOUBLE_EconL   = 8      ;/* exponent continuation length    */
  #DECDOUBLE_Declets =5      ;/* count of declets                */
  ;/* highest biased exponent (Elimit-1) */
  #DECDOUBLE_Ehigh = (#DECDOUBLE_Emax + #DECDOUBLE_Bias - (#DECDOUBLE_Pmax-1))

  ;/* Required includes                                                */
  XIncludeFile "decContext.pbi"
  XIncludeFile "decQuad.pbi"
  CompilerIf Defined(DECIMAL64, #PB_Constant)=0
    XIncludeFile "decimal64.pbi"              ;/*  Decimal 64-bit format module */
  CompilerEndIf

  ;/* The decDouble decimal 64-bit type, accessible by all sizes */
  Structure decDouble
	StructureUnion
    		bytes.uint8_t[#DECDOUBLE_Bytes];   ;/* fields: 1, 5, 8, 50 bits */
    		shorts.uint16_t[#DECDOUBLE_Bytes/2];
    		words.uint32_t [#DECDOUBLE_Bytes/4];
    		CompilerIf Defined(DECUSE64, #PB_Constant)
			    CompilerIf #DECUSE64
    				longs.uint64_t[#DECDOUBLE_Bytes/8]
			    CompilerEndIf
    		CompilerEndIf
	EndStructureUnion
  EndStructure

  ImportC "/usr/local/lib/libDecNumber.a"
  ;/* ---------------------------------------------------------------- */
  ;/* Routines -- implemented as decFloat routines in common files     */
  ;/* ---------------------------------------------------------------- */

  ;/* Utilities and conversions, extractors, etc.) */
  	decDoubleFromBCD(*a.decDouble , b.int32_t, *c.BYTE , d.int32_t);decDouble * 
  	decDoubleFromInt32(*a.decDouble , b.int32_t);decDouble * 
  	decDoubleFromPacked(*a.decDouble , b.int32_t, *c.BYTE );decDouble * 
  	decDoubleFromPackedChecked(*a.decDouble , b.int32_t, *c.BYTE );decDouble * 
  	decDoubleFromString(*a.decDouble , s.p-ascii, *c.decContext );decDouble * 
  	decDoubleFromUInt32(*a.decDouble , b.uint32_t);decDouble * 
  	decDoubleFromWider(*a.decDouble , *b.decQuad , *c.decContext );decDouble * 
  	decDoubleGetCoefficient(*a.decDouble , *b.BYTE );int32_t     
  	decDoubleGetExponent(*a.decDouble );int32_t     
  	decDoubleSetCoefficient(*a.decDouble , *b.BYTE , c.int32_t);decDouble * 
  	decDoubleSetExponent(decDouble , *b.decContext , c.int32_t);decDouble * 
  	decDoubleShow(*a.decDouble , s.p-ascii);void        
  	decDoubleToBCD(*a.decDouble , *b.LONG , *c.BYTE );int32_t     
  	decDoubleToEngString(*a.decDouble , *b.p-ascii);char      * 
  	decDoubleToInt32(*a.decDouble , *b.decContext , rounding.l);int32_t     
  	decDoubleToInt32Exact(*a.decDouble , *b.decContext , rounding.l);int32_t     
  	decDoubleToPacked(*a.decDouble , *b.LONG , *c.BYTE );int32_t     
  	decDoubleToString(*a.decDouble , *b.p-ascii);char      * 
  	decDoubleToUInt32(*a.decDouble , *b.decContext , rounding.l);uint32_t    
  	decDoubleToUInt32Exact(*a.decDouble , *b.decContext , rounding.l);uint32_t    
  	decDoubleToWider(*a.decDouble , *b.decQuad );decQuad   * 
  	decDoubleZero(*a.decDouble );decDouble * 

  ;/* Computational (result is a decDouble) */
  	decDoubleAbs(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleAdd(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleAnd(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleDivide(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleDivideInteger(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleFMA(*a.decDouble , *b.decDouble , *c.decDouble , *d.decDouble , *e.decContext );decDouble * 
  	decDoubleInvert(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleLogB(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleMax(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleMaxMag(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleMin(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleMinMag(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleMinus(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleMultiply(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleNextMinus(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleNextPlus(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleNextToward(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleOr(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoublePlus(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleQuantize(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleReduce(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleRemainder(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleRemainderNear(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleRotate(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleScaleB(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleShift(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleSubtract(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleToIntegralValue(*a.decDouble , *b.decDouble , *c.decContext , rounding.l);decDouble * 
  	decDoubleToIntegralExact(*a.decDouble , *b.decDouble , *c.decContext );decDouble * 
  	decDoubleXor(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 

  ;/* Comparisons */
  	decDoubleCompare(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleCompareSignal(*a.decDouble , *b.decDouble , *c.decDouble , *d.decContext );decDouble * 
  	decDoubleCompareTotal(*a.decDouble , *b.decDouble , *c.decDouble );decDouble * 
  	decDoubleCompareTotalMag(*a.decDouble , *b.decDouble , *c.decDouble );decDouble * 

  ;/* Copies */
  	decDoubleCanonical(*a.decDouble , *b.decDouble );decDouble * 
  	decDoubleCopy(*a.decDouble , *b.decDouble );decDouble * 
  	decDoubleCopyAbs(*a.decDouble , *b.decDouble );decDouble * 
  	decDoubleCopyNegate(*a.decDouble , *b.decDouble );decDouble * 
  	decDoubleCopySign(*a.decDouble , *b.decDouble , *c.decDouble );decDouble * 

  ;/* Non-computational */
  	decDoubleClass(*a.decDouble );enum decClass 
  	decDoubleClassString(*a.decDouble );const char *  
  	decDoubleDigits(*a.decDouble );uint32_t
  	decDoubleIsCanonical(*a.decDouble );uint32_t
  	decDoubleIsFinite(*a.decDouble );uint32_t
  	decDoubleIsInfinite(*a.decDouble );uint32_t
  	decDoubleIsInteger(*a.decDouble );uint32_t
  	decDoubleIsNaN(*a.decDouble );uint32_t
  	decDoubleIsNormal(*a.decDouble );uint32_t
  	decDoubleIsSignaling(*a.decDouble );uint32_t
  	decDoubleIsSignalling(*a.decDouble );uint32_t
  	decDoubleIsSigned(*a.decDouble );uint32_t
  	decDoubleIsSubnormal(*a.decDouble );uint32_t
  	decDoubleIsZero(*a.decDouble );uint32_t
  	decDoubleRadix(*a.decDouble );uint32_t
  	decDoubleSameQuantum(*a.decDouble , *b.decDouble );uint32_t
  	decDoubleVersion();const char *  
  EndImport
  ;/* decNumber conversions; these are implemented as macros so as not  */
  ;/* to force a dependency on decimal64 and decNumber in decDouble.    */
  ;/* decDoubleFromNumber returns a decimal64 * to avoid warnings.      */
  Macro decDoubleToNumber(dq, dn)
    decimal64ToNumber((dq), dn)
  EndMacro
  Macro decDoubleFromNumber(dq, dn, set)
    decimal64FromNumber((dq), dn, set)
  EndMacro

CompilerEndIf

Re: decNumber pbi

Posted: Sun Feb 12, 2017 12:41 pm
by jack
decimal64.pbi

Code: Select all

;/* ------------------------------------------------------------------ */
;/* Decimal 64-bit format module header                                */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2000, 2005.  All rights reserved.   */
;/*                                                                    */
;/* This software is made available under the terms of the             */
;/* ICU License -- ICU 1.8.1 and later.                                */
;/*                                                                    */
;/* The description and User's Guide ("The decNumber C Library") for   */
;/* this software is called decNumber.pdf.  This document is           */
;/* available, together with arithmetic and format specifications,     */
;/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
;/*                                                                    */
;/* Please send comments, suggestions, and corrections to the author:  */
;/*   mfc@uk.ibm.com                                                   */
;/*   Mike Cowlishaw, IBM Fellow                                       */
;/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
;/* ------------------------------------------------------------------ */

CompilerIf Defined(DECIMAL64, #PB_Constant)=0
  #DECIMAL64     = 1
  #DEC64NAME     = "decimal64"                   ;/* Short name   */
  #DEC64FULLNAME = "Decimal 64-bit Number"       ;/* Verbose name */
  #DEC64AUTHOR   = "Mike Cowlishaw"              ;/* Who to blame */


  ;/* parameters for decimal64s                                        */
  #DECIMAL64_Bytes  = 8            ;/* length                     */
  #DECIMAL64_Pmax   = 16           ;/* maximum precision (digits) */
  #DECIMAL64_Emax   = 384          ;/* maximum adjusted exponent  */
  #DECIMAL64_Emin   =-383          ;/* minimum adjusted exponent  */
  #DECIMAL64_Bias   = 398          ;/* bias for the exponent      */
  #DECIMAL64_String = 24           ;/* maximum string length, +1  */
  #DECIMAL64_EconL  = 8            ;/* exp. continuation length   */
  ;/* highest biased exponent (Elimit-1)                               */
  #DECIMAL64_Ehigh  = (#DECIMAL64_Emax+#DECIMAL64_Bias-#DECIMAL64_Pmax+1)

  ;/* check enough digits, if pre-defined                              */
  CompilerIf Defined(DECNUMDIGITS, #PB_Constant)
    CompilerIf (#DECNUMDIGITS<#DECIMAL64_Pmax)
      ;syntax error is on purpose, so you would see the next line
      Error", "decimal64.pbi needs pre-defined DECNUMDIGITS>=16 For safe use"
    CompilerEndIf
  CompilerEndIf


  CompilerIf Defined(DECNUMDIGITS, #PB_Constant)=0
    #DECNUMDIGITS = #DECIMAL64_Pmax ;/* size if not already defined*/
  CompilerEndIf
  CompilerIf Defined(DECNUMBER, #PB_Constant)=0
    XIncludeFile "decNumber.pbi"              ;/* context and number library */
  CompilerEndIf

  ;/* Decimal 64-bit type, accessible by bytes                         */
  Structure decimal64
    bytes.uint8_t[#DECIMAL64_Bytes];     ;/* decimal64: 1, 5, 8, 50 bits*/
  EndStructure

  ;/* special values [top byte excluding sign bit; last two bits are   */
  ;/* don't-care for Infinity on input, last bit don't-care for NaN]   */
  CompilerIf Defined(DECIMAL_NaN, #PB_Constant)=0
    #DECIMAL_NaN     = $7c        ;/* 0 11111 00 NaN             */
    #DECIMAL_sNaN    = $7e        ;/* 0 11111 10 sNaN            */
    #DECIMAL_Inf     = $78        ;/* 0 11110 00 Infinity        */
  CompilerEndIf

  ;/* ---------------------------------------------------------------- */
  ;/* Routines                                                         */
  ;/* ---------------------------------------------------------------- */
  ;/* String conversions                                               */
  ImportC "/usr/local/lib/libDecNumber.a"
  	decimal64FromString(*a.decimal64 , s.p-ascii, *c.decContext );decimal64 * 
  	decimal64ToString(*a.decimal64 , *s.p-ascii);char * 
  	decimal64ToEngString(*a.decimal64 , *s.p-ascii);char * 

  	;/* decNumber conversions                                            */
  	decimal64FromNumber(*a.decimal64 , *b.decNumber , *c.decContext );decimal64 * 
  	decimal64ToNumber(*a.decimal64 , *b.decNumber );decNumber * 

  	;/* Format-dependent utilities                                       */
  	decimal64IsCanonical(*a.decimal64 );uint32_t    
  	decimal64Canonical(*a.decimal64 , *b.decimal64 );decimal64 * 
  EndImport
CompilerEndIf

Re: decNumber pbi

Posted: Sun Feb 12, 2017 12:42 pm
by jack
decQuad.pbi

Code: Select all

;/* ------------------------------------------------------------------ */
;/* decQuad.h -- Decimal 128-bit format module header                  */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
;/*                                                                    */
;/* This software is made available under the terms of the             */
;/* ICU License -- ICU 1.8.1 and later.                                */
;/*                                                                    */
;/* Please send comments, suggestions, and corrections to the author:  */
;/*   mfc@uk.ibm.com  (Mike Cowlishaw FREng, IBM Fellow,               */
;/*   IBM UK MP8, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK     */
;/* ------------------------------------------------------------------ */
;/* This include file is always included by decSingle and decDouble,   */
;/* and therefore also holds useful constants used by all three.       */

CompilerIf Defined(DECQUAD, #PB_Constant)=0
  #DECQUAD = 1

  #DECQUADNAME         = "decimalQuad"           ;/* Short name   */
  #DECQUADTITLE        = "Decimal 128-bit datum" ;/* Verbose name */
  #DECQUADAUTHOR       = "Mike Cowlishaw"        ;/* Who to blame */

  ;/* parameters for decQuads */
  #DECQUAD_Bytes   =    16      ;/* length                          */
  #DECQUAD_Pmax    =    34      ;/* maximum precision (digits)      */
  #DECQUAD_Emin    = -6143      ;/* minimum adjusted exponent       */
  #DECQUAD_Emax    =  6144      ;/* maximum adjusted exponent       */
  #DECQUAD_EmaxD   =     4      ;/* maximum exponent digits         */
  #DECQUAD_Bias    =  6176      ;/* bias for the exponent           */
  #DECQUAD_String  =    43      ;/* maximum string length, +1       */
  #DECQUAD_EconL   =    12      ;/* exponent continuation length    */
  #DECQUAD_Declets =    11      ;/* count of declets                */
  ;/* highest biased exponent (Elimit-1) */
  #DECQUAD_Ehigh = (#DECQUAD_Emax + #DECQUAD_Bias - (#DECQUAD_Pmax-1))

  ;/* Required include                                                 */
  XIncludeFile "decContext.pbi"
  CompilerIf Defined(DECIMAL128, #PB_Constant)=0
    XIncludeFile "decimal128.pbi"              ;/*  Decimal 128-bit format module */
  CompilerEndIf

  ;/* The decQuad decimal 128-bit type, accessible by all sizes */
  Structure decQuad
	  StructureUnion
  		  bytes.uint8_t[#DECQUAD_Bytes];     ;/* fields: 1, 5, 12, 110 bits */
    		shorts.uint16_t[#DECQUAD_Bytes/2];
    		words.uint32_t[#DECQUAD_Bytes/4];
    		CompilerIf Defined(DECUSE64, #PB_Constant)
			    CompilerIf #DECUSE64
      				longs.uint64_t[#DECQUAD_Bytes/8];
    			CompilerEndIf
		    CompilerEndIf
  	EndStructureUnion
  EndStructure

  ;/* ---------------------------------------------------------------- */
  ;/* Shared constants                                                 */
  ;/* ---------------------------------------------------------------- */

  ;/* sign and special values [top 32-bits; last two bits are don't-care
  ;   For Infinity on input, last bit don't-care for NaNs] */
  #DECFLOAT_Sign  = $80000000     ;/* 1 00000 00 Sign */
  #DECFLOAT_NaN   = $7c000000     ;/* 0 11111 00 NaN generic */
  #DECFLOAT_qNaN  = $7c000000     ;/* 0 11111 00 qNaN */
  #DECFLOAT_sNaN  = $7e000000     ;/* 0 11111 10 sNaN */
  #DECFLOAT_Inf   = $78000000     ;/* 0 11110 00 Infinity */
  #DECFLOAT_MinSp = $78000000     ;/* minimum special value */
                                        ;/* [specials are all >=MinSp] */
  ;/* Sign nibble constants                                            */
  CompilerIf Defined(DECPPLUSALT, #PB_Constant)=0
    #DECPPLUSALT  = $0A ;/* alternate plus  nibble               */
    #DECPMINUSALT = $0B ;/* alternate minus nibble               */
    #DECPPLUS     = $0C ;/* preferred plus  nibble               */
    #DECPMINUS    = $0D ;/* preferred minus nibble               */
    #DECPPLUSALT2 = $0E ;/* alternate plus  nibble               */
    #DECPUNSIGNED = $0F ;/* alternate plus  nibble (unsigned)    */
  CompilerEndIf

  ;/* ---------------------------------------------------------------- */
  ;/* Routines -- implemented as decFloat routines in common files     */
  ;/* ---------------------------------------------------------------- */

  ;/* Utilities and conversions, extractors, etc.) */
  ImportC "/usr/local/lib/libDecNumber.a"
    decQuadFromBCD(*a.decQuad , b.int32_t, *c.BYTE , d.int32_t);decQuad * 
    decQuadFromInt32(*a.decQuad , b.int32_t);decQuad * 
    decQuadFromPacked(*a.decQuad , b.int32_t, *c.BYTE );decQuad * 
    decQuadFromPackedChecked(*a.decQuad , b.int32_t, *c.BYTE );decQuad * 
    decQuadFromString(*a.decQuad , s.p-ascii, *c.decContext );decQuad * 
    decQuadFromUInt32(*a.decQuad , b.uint32_t);decQuad * 
    decQuadGetCoefficient(*a.decQuad , *b.BYTE );int32_t   
    decQuadGetExponent(*a.decQuad );int32_t   
    decQuadSetCoefficient(*a.decQuad , *b.BYTE , c.int32_t);decQuad * 
    decQuadSetExponent(*a.decQuad , *b.decContext , c.int32_t);decQuad * 
    decQuadShow(*a.decQuad , s.p-ascii);void      
    decQuadToBCD(*a.decQuad , *b.LONG , *c.BYTE );int32_t   
    decQuadToEngString(*a.decQuad , *s.p-ascii);char    * 
    decQuadToInt32(*a.decQuad , *b.decContext , rounding.l);int32_t   
    decQuadToInt32Exact(*a.decQuad , *b.decContext , rounding.l);int32_t   
    decQuadToPacked(*a.decQuad , *b.LONG , *c.BYTE );int32_t   
    decQuadToString(*a.decQuad , *s.p-ascii);char    * 
    decQuadToUInt32(*a.decQuad , *b.decContext , rounding.l);uint32_t  
    decQuadToUInt32Exact(*a.decQuad , *b.decContext , rounding.l);uint32_t  
    decQuadZero(*a.decQuad );decQuad * 

  ;/* Computational (result is a decQuad) */
    decQuadAbs(*a.decQuad , *b.decQuad , *c.decContext );decQuad * 
    decQuadAdd(*a.decQuad , *b.decQuad , *c.decQuad , *d.decContext );decQuad * 
    decQuadAnd(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadDivide(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadDivideInteger(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadFMA(*a.decQuad, *b.decQuad, *c.decQuad, *d.decQuad, *e.decContext);decQuad * 
    decQuadInvert(*a.decQuad, *b.decQuad, *c.decContext);decQuad * 
    decQuadLogB(*a.decQuad, *b.decQuad, *c.decContext);decQuad * 
    decQuadMax(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadMaxMag(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadMin(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadMinMag(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadMinus(*a.decQuad, *b.decQuad, *c.decContext);decQuad * 
    decQuadMultiply(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadNextMinus(*a.decQuad, *b.decQuad, *c.decContext);decQuad * 
    decQuadNextPlus(*a.decQuad, *b.decQuad, *c.decContext);decQuad * 
    decQuadNextToward(*a.decQuad, *b.decQuad, *c.decQuad, decContext);decQuad * 
    decQuadOr(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadPlus(*a.decQuad, *b.decQuad, *c.decContext);decQuad * 
    decQuadQuantize(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadReduce(*a.decQuad, *b.decQuad, *c.decContext);decQuad * 
    decQuadRemainder(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadRemainderNear(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadRotate(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadScaleB(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadShift(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadSubtract(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadToIntegralValue(*a.decQuad, *b.decQuad, *c.decContext, rounding.l);decQuad * 
    decQuadToIntegralExact(*a.decQuad, *b.decQuad, *c.decContext);decQuad * 
    decQuadXor(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 

  ;/* Comparisons */
    decQuadCompare(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadCompareSignal(*a.decQuad, *b.decQuad, *c.decQuad, *d.decContext);decQuad * 
    decQuadCompareTotal(*a.decQuad, *b.decQuad, *c.decQuad);decQuad * 
    decQuadCompareTotalMag(*a.decQuad, *b.decQuad, *c.decQuad);decQuad * 

  ;/* Copies */
    decQuadCanonical(*a.decQuad, *b.decQuad);decQuad * 
    decQuadCopy(*a.decQuad, *b.decQuad);decQuad * 
    decQuadCopyAbs(*a.decQuad, *b.decQuad);decQuad * 
    decQuadCopyNegate(*a.decQuad, *b.decQuad);decQuad * 
    decQuadCopySign(*a.decQuad, *b.decQuad, *c.decQuad);decQuad * 

  ;/* Non-computational */
    decQuadClass(*a.decQuad);enum decClass 
    decQuadClassString(*a.decQuad);const char *  
    decQuadDigits(*a.decQuad);uint32_t      
    decQuadIsCanonical(*a.decQuad);uint32_t      
    decQuadIsFinite(*a.decQuad);uint32_t      
    decQuadIsInteger(*a.decQuad);uint32_t      
    decQuadIsInfinite(*a.decQuad);uint32_t      
    decQuadIsNaN(*a.decQuad);uint32_t      
    decQuadIsNormal(*a.decQuad);uint32_t      
    decQuadIsSignaling(*a.decQuad);uint32_t      
    decQuadIsSignalling(*a.decQuad);uint32_t      
    decQuadIsSigned(*a.decQuad);uint32_t      
    decQuadIsSubnormal(*a.decQuad);uint32_t      
    decQuadIsZero(*a.decQuad);uint32_t      
    decQuadRadix(*a.decQuad);uint32_t      
    decQuadSameQuantum(*a.decQuad, *b.decQuad);uint32_t      
    decQuadVersion();const char *  
  EndImport

  ;/* decNumber conversions; these are implemented as macros so as not  */
  ;/* to force a dependency on decimal128 and decNumber in decQuad.     */
  ;/* decQuadFromNumber returns a decimal128 * to avoid warnings.       */
  Macro decQuadToNumber(dq, dn)
    decimal128ToNumber(dq, dn)
  EndMacro
  Macro decQuadFromNumber(dq, dn, set)
    decimal128FromNumber(dq, dn, set)
  EndMacro
CompilerEndIf

Re: decNumber pbi

Posted: Sun Feb 12, 2017 12:43 pm
by jack
decimal128.pbi

Code: Select all

;/* ------------------------------------------------------------------ */
;/* Decimal 128-bit format module header                               */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2000, 2005.  All rights reserved.   */
;/*                                                                    */
;/* This software is made available under the terms of the             */
;/* ICU License -- ICU 1.8.1 and later.                                */
;/*                                                                    */
;/* The description and User's Guide ("The decNumber C Library") for   */
;/* this software is called decNumber.pdf.  This document is           */
;/* available, together with arithmetic and format specifications,     */
;/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
;/*                                                                    */
;/* Please send comments, suggestions, and corrections to the author:  */
;/*   mfc@uk.ibm.com                                                   */
;/*   Mike Cowlishaw, IBM Fellow                                       */
;/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
;/* ------------------------------------------------------------------ */

CompilerIf Defined(DECIMAL128, #PB_Constant)=0
  #DECIMAL128 = 1
  #DEC128NAME     = "decimal128"                 ;/* Short name   */
  #DEC128FULLNAME = "Decimal 128-bit Number"     ;/* Verbose name */
  #DEC128AUTHOR   = "Mike Cowlishaw"             ;/* Who to blame */

  ;/* parameters for decimal128s */
  #DECIMAL128_Bytes  = 16          ;/* length                     */
  #DECIMAL128_Pmax   = 34          ;/* maximum precision (digits) */
  #DECIMAL128_Emax   = 6144        ;/* maximum adjusted exponent  */
  #DECIMAL128_Emin   =-6143        ;/* minimum adjusted exponent  */
  #DECIMAL128_Bias   = 6176        ;/* bias for the exponent      */
  #DECIMAL128_String = 43          ;/* maximum string length, +1  */
  #DECIMAL128_EconL  = 12          ;/* exp. continuation length   */
  ;/* highest biased exponent (Elimit-1)                               */
  #DECIMAL128_Ehigh  = (#DECIMAL128_Emax+#DECIMAL128_Bias-#DECIMAL128_Pmax+1)

  ;/* check enough digits, if pre-defined                              */
  CompilerIf Defined(DECNUMDIGITS, #PB_Constant)
    CompilerIf (#DECNUMDIGITS<#DECIMAL128_Pmax)
      ;syntax error is on purpose, so you would see the next line
      "Error", "decimal128.pbi needs pre-defined DECNUMDIGITS>=34 for safe use"
    CompilerEndIf
  CompilerEndIf

  CompilerIf Defined(DECNUMDIGITS, #PB_Constant)=0
    #DECNUMDIGITS = #DECIMAL128_Pmax ;/* size if not already defined*/
  CompilerEndIf
  CompilerIf Defined(DECNUMBER, #PB_Constant)=0
    XIncludeFile "decNumber.pbi"              ;/* context and number library */
  CompilerEndIf

  ;/* Decimal 128-bit type, accessible by bytes                        */
  Structure decimal128
    bytes.uint8_t[#DECIMAL128_Bytes]; ;/* decimal128: 1, 5, 12, 110 bits*/
  EndStructure

  ;/* special values [top byte excluding sign bit; last two bits are   */
  ;/* don't-care for Infinity on input, last bit don't-care for NaN]   */
  CompilerIf Defined(DECIMAL_NaN, #PB_Constant)=0
    #DECIMAL_NaN     = $7c        ;/* 0 11111 00 NaN             */
    #DECIMAL_sNaN    = $7e        ;/* 0 11111 10 sNaN            */
    #DECIMAL_Inf     = $78        ;/* 0 11110 00 Infinity        */
  CompilerEndIf

  ;/* ---------------------------------------------------------------- */
  ;/* Routines                                                         */
  ;/* ---------------------------------------------------------------- */
  ;/* String conversions                                               */
  ImportC "/usr/local/lib/libDecNumber.a"
  	decimal128FromString(*a.decimal128 , s.p-ascii, *c.decContext );decimal128 * 
  	decimal128ToString(*a.decimal128 , *s.p-ascii);char * 
  	decimal128ToEngString(*a.decimal128 , *s.p-ascii);char * 

  	;/* decNumber conversions                                            */
  	decimal128FromNumber(*a.decimal128 , *b.decNumber , *c.decContext );decimal128 * 
  	decimal128ToNumber(*a.decimal128 , *b.decNumber );decNumber * 

  	;/* Format-dependent utilities                                       */
  	decimal128IsCanonical(*a.decimal128 );uint32_t    
  	decimal128Canonical(*a.decimal128 , *b.decimal128 );decimal128 * 
  EndImport
CompilerEndIf

Re: decNumber pbi

Posted: Sun Feb 12, 2017 12:45 pm
by jack
decNumber.pbi

Code: Select all

;/* ------------------------------------------------------------------ */
;/* Decimal Number arithmetic module header                            */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
;/*                                                                    */
;/* This software is made available under the terms of the             */
;/* ICU License -- ICU 1.8.1 and later.                                */
;/*                                                                    */
;/* The description and User's Guide ("The decNumber C Library") for   */
;/* this software is called decNumber.pdf.  This document is           */
;/* available, together with arithmetic and format specifications,     */
;/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
;/*                                                                    */
;/* Please send comments, suggestions, and corrections to the author:  */
;/*   mfc@uk.ibm.com                                                   */
;/*   Mike Cowlishaw, IBM Fellow                                       */
;/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
;/* ------------------------------------------------------------------ */

CompilerIf Defined(DECNUMBER, #PB_Constant)=0
  #DECNUMBER   =1
  #DECNAME     ="decNumber"                       ;/* Short name */
  #DECFULLNAME ="Decimal Number Module"         ;/* Verbose name */
  #DECAUTHOR   ="Mike Cowlishaw"                ;/* Who to blame */

  CompilerIf Defined(DECCONTEXT, #PB_Constant)=0
    XIncludeFile "decContext.pbi"
  CompilerEndIf

  ;/* Bit settings for decNumber.bits                                  */
  #DECNEG    = $80      ;/* Sign; 1=negative, 0=positive or zero */
  #DECINF    = $40      ;/* 1=Infinity                           */
  #DECNAN    = $20      ;/* 1=NaN                                */
  #DECSNAN   = $10      ;/* 1=sNaN                               */
  ;/* The remaining bits are reserved; they must be 0                  */
  #DECSPECIAL = (#DECINF|#DECNAN|#DECSNAN) ;/* any special value     */

  ;/* Define the decNumber data structure.  The size and shape of the  */
  ;/* units array in the structure is determined by the following      */
  ;/* constant.  This must not be changed without recompiling the      */
  ;/* decNumber library modules. */

  #DECDPUN = 3           ;/* DECimal Digits Per UNit [must be >0  */
                              ;/* and <10; 3 or powers of 2 are best]. */

  ;/* DECNUMDIGITS is the default number of digits that can be held in */
  ;/* the structure.  If undefined, 1 is assumed and it is assumed     */
  ;/* that the structure will be immediately followed by extra space,  */
  ;/* as required.  DECNUMDIGITS is always >0.                         */
  CompilerIf Defined(DECNUMDIGITS, #PB_Constant)=0
    #DECNUMDIGITS = 1
  CompilerEndIf

  ;/* The size (integer data type) of each unit is determined by the   */
  ;/* number of digits it will hold.                                   */
  CompilerIf #DECDPUN<=2
    Macro decNumberUnits
      uint8_t
    EndMacro
  CompilerElse
    CompilerIf #DECDPUN<=4
      Macro decNumberUnits
        uint16_t
      EndMacro
    CompilerElse
      Macro decNumberUnits
        uint32_t
      EndMacro
    CompilerEndIf  
  CompilerEndIf
  ;/* The number of units needed is ceil(DECNUMDIGITS/DECDPUN)         */
  #DECNUMUNITS =((#DECNUMDIGITS+#DECDPUN-1)/#DECDPUN)

  ;/* The data structure... */
  Structure decNumber
    digits.int32_t      ;/* Count of digits in the coefficient; >0    */
    exponent.int32_t    ;/* Unadjusted exponent, unbiased, in         */
                         ;/* range: -1999999997 through 999999999      */
    bits.uint8_t        ;/* Indicator bits (see above)                */
                         ;/* Coefficient, from least significant unit  */
    lsu.decNumberUnits[#DECNUMUNITS];
   EndStructure

  ;/* Notes:                                                           */
  ;/* 1. If digits is > DECDPUN then there will one or more            */
  ;/*    decNumberUnits immediately following the first element of lsu.*/
  ;/*    These contain the remaining (more significant) digits of the  */
  ;/*    number, and may be in the lsu array, or may be guaranteed by  */
  ;/*    some other mechanism (such as being contained in another      */
  ;/*    structure, or being overlaid on dynamically allocated         */
  ;/*    storage).                                                     */
  ;/*                                                                  */
  ;/*    Each integer of the coefficient (except potentially the last) */
  ;/*    contains DECDPUN digits (e.g., a value in the range 0 through */
  ;/*    99999999 if DECDPUN is 8, or 0 through 999 if DECDPUN is 3).  */
  ;/*                                                                  */
  ;/* 2. A decNumber converted to a string may need up to digits+14    */
  ;/*    characters.  The worst cases (non-exponential and exponential */
  ;/*    formats) are -0.00000{9...}# and -9.{9...}E+999999999#        */
  ;/*    (where # is '\0')                                             */


ImportC "/usr/local/lib/libDecNumber.a"
  ;/* ---------------------------------------------------------------- */
  ;/* decNumber public functions and macros                            */
  ;/* ---------------------------------------------------------------- */
  ;/* Conversions                                                      */
  decNumberFromInt32(*a.decNumber , b.int32_t);decNumber * 
  decNumberFromUInt32(*a.decNumber , b.uint32_t);decNumber * 
  decNumberFromString(*a.decNumber , b.p-ascii, *c.decContext );decNumber * 
  decNumberToString(*a.decNumber , *s.p-ascii);char      * 
  decNumberToEngString(*a.decNumber , *s.p-ascii);char      * 
  decNumberToUInt32(*a.decNumber , *b.decContext);uint32_t    
  decNumberToInt32(*a.decNumber , *b.decContext );int32_t     
  decNumberGetBCD(*a.decNumber , *b.BYTE);uint8_t   * 
  decNumberSetBCD(*a.decNumber , *b.BYTE, c.uint32_t);decNumber * 

  ;/* Operators and elementary functions                               */
  decNumberAbs(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberAdd(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberAnd(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberCompare(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberCompareSignal(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberCompareTotal(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberCompareTotalMag(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberDivide(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberDivideInteger(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberExp(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberFMA(*a.decNumber , *b.decNumber , *c.decNumber , *d.decNumber , *e.decContext );decNumber * 
  decNumberInvert(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberLn(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberLogB(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberLog10(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberMax(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberMaxMag(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberMin(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberMinMag(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberMinus(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberMultiply(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberNormalize(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberOr(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberPlus(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberPower(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberQuantize(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberReduce(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberRemainder(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberRemainderNear(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberRescale(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberRotate(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberSameQuantum(*a.decNumber , *b.decNumber , *c.decNumber );decNumber * 
  decNumberScaleB(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberShift(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberSquareRoot(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberSubtract(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 
  decNumberToIntegralExact(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberToIntegralValue(*a.decNumber , *b.decNumber , *c.decContext );decNumber * 
  decNumberXor(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber * 

  ;/* Utilities                                                        */
  decNumberClass(*a.decNumber , *b.decContext );enum decClass 
  decNumberClassToString(a.l);const char * 
  decNumberCopy(*a.decNumber , *b.decNumber );decNumber  * 
  decNumberCopyAbs(*a.decNumber , *b.decNumber );decNumber  * 
  decNumberCopyNegate(*a.decNumber , *b.decNumber );decNumber  * 
  decNumberCopySign(*a.decNumber , *b.decNumber , *c.decNumber );decNumber  * 
  decNumberNextMinus(*a.decNumber , *b.decNumber , *c.decContext );decNumber  * 
  decNumberNextPlus(*a.decNumber , *b.decNumber , *c.decContext );decNumber  * 
  decNumberNextToward(*a.decNumber , *b.decNumber , *c.decNumber , *d.decContext );decNumber  * 
  decNumberTrim(*a.decNumber );decNumber  * 
  decNumberVersion();const char * 
  decNumberZero(*a.decNumber );decNumber  * 

  ;/* Functions for testing decNumbers (normality depends on context)  */
  decNumberIsNormal(*a.decNumber , *b.decContext );int32_t 
  decNumberIsSubnormal(*a.decNumber , *b.decContext );int32_t 
EndImport

;-------------------------------------------------------------------------
  ;/* Macros for testing decNumber *dn                                 */
  Macro decNumberIsCanonical(dn)
    (1)  ;/* All decNumbers are saintly */
  EndMacro
  
  Macro decNumberIsFinite(dn)
    (((dn\bits&#DECSPECIAL)=0) Or 0)
  EndMacro
  
  Macro decNumberIsInfinite(dn)
    (((dn\bits&#DECINF)<>0) Or 0)
  EndMacro
  
  Macro decNumberIsNaN(dn)
    (((dn\bits&(#DECNAN|#DECSNAN))<>0) Or 0)
  EndMacro
  
  Macro decNumberIsNegative(dn)
    (((dn\bits&#DECNEG)<>0) Or 0)
  EndMacro
  
  Macro decNumberIsQNaN(dn)
    (((dn\bits&(#DECNAN))<>0) Or 0)
  EndMacro
  
  Macro decNumberIsSNaN(dn)
    (((dn\bits&(#DECSNAN))<>0) Or 0)
  EndMacro
  
  Macro decNumberIsSpecial(dn)
    (((dn\bits&#DECSPECIAL)<>0) Or 0)
  EndMacro
  
  Macro decNumberIsZero(dn)
    ((dn\lsu=0) And (dn\digits=1) And (((dn\bits&#DECSPECIAL)=0)) Or 0)
  EndMacro
  
  Macro decNumberRadix(dn)
    (10)
  EndMacro

CompilerEndIf

Re: decNumber pbi

Posted: Sun Feb 12, 2017 12:47 pm
by jack
decPacked.pbi

Code: Select all

;/* ------------------------------------------------------------------ */
;/* Packed Decimal conversion module header                            */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2000, 2005.  All rights reserved.   */
;/*                                                                    */
;/* This software is made available under the terms of the             */
;/* ICU License -- ICU 1.8.1 and later.                                */
;/*                                                                    */
;/* The description and User's Guide ("The decNumber C Library") for   */
;/* this software is called decNumber.pdf.  This document is           */
;/* available, together with arithmetic and format specifications,     */
;/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
;/*                                                                    */
;/* Please send comments, suggestions, and corrections to the author:  */
;/*   mfc@uk.ibm.com                                                   */
;/*   Mike Cowlishaw, IBM Fellow                                       */
;/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
;/* ------------------------------------------------------------------ */

CompilerIf Defined(DECPACKED, #PB_Constant)=0
  #DECPACKED    = 1
  #DECPNAME     = "decPacked"                      ;/* Short name */
  #DECPFULLNAME = "Packed Decimal conversions"   ;/* Verbose name */
  #DECPAUTHOR   = "Mike Cowlishaw"               ;/* Who to blame */

  #DECPACKED_DefP = 32             ;/* default precision          */

  CompilerIf  Defined(DECNUMDIGITS, #PB_Constant)=0
    #DECNUMDIGITS = #DECPACKED_DefP ;/* size if not already defined*/
  CompilerEndIf
  XIncludeFile "decNumber.pbi"                ;/* context and number library */

  ;/* Sign nibble constants                                            */
  CompilerIf Defined(DECPPLUSALT, #PB_Constant)=0
    #DECPPLUSALT  = $0A ;/* alternate plus  nibble               */
    #DECPMINUSALT = $0B ;/* alternate minus nibble               */
    #DECPPLUS     = $0C ;/* preferred plus  nibble               */
    #DECPMINUS    = $0D ;/* preferred minus nibble               */
    #DECPPLUSALT2 = $0E ;/* alternate plus  nibble               */
    #DECPUNSIGNED = $0F ;/* alternate plus  nibble (unsigned)    */
  CompilerEndIf
  ImportC "/usr/local/lib/libDecNumber.a"
	  ;/* ---------------------------------------------------------------- */
	  ;/* decPacked public routines                                        */
	  ;/* ---------------------------------------------------------------- */
	  ;/* Conversions                                                      */
	  decPackedFromNumber(*a.BYTE , b.int32_t, *c.LONG , *d.decNumber );uint8_t * 
	  decPackedToNumber(*a.BYTE , b.int32_t, *c.LONG , *d.decNumber );decNumber * 
  EndImport

CompilerEndIf

Re: decNumber pbi

Posted: Sun Feb 12, 2017 12:49 pm
by jack
example4.pb

Code: Select all

OpenConsole()
ConsoleTitle("Calculate Compound Interest")

;/* ------------------------------------------------------------------ */
;/* Decimal Number Library Demonstration program                       */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2001.  All rights reserved.         */
;/* ----------------------------------------------------------------+- */
;/*                                                 right margin -->|  */

;// example4.c -- add two numbers, active error handling
#DECNUMDIGITS = 38                         ; work with up to 38 digits

XIncludeFile("decNumber.pbi")
XIncludeFile("decQuad.pbi")
XIncludeFile("decimal128.pbi")

Define.decNumber one, mtwo, hundred       ; constants
Define.decNumber start, rate, years       ; parameters
Define.decNumber total                    ; result
Define.decContext set                     ; working context
Define.s s1, s2, s3

Define.decquad nq

*buffer = AllocateMemory(#DECNUMDIGITS*2+16) ; conversion buffer
*errmsg=AllocateMemory(80)

decContextDefault (@set, #DEC_INIT_BASE)  ; initialize
set\traps = 0                             ; no traps
set\digits = 25                           ; precision 25
decNumberFromString (@one,      "1", @set); set constants
decNumberFromString (@mtwo,    "-2", @set)
decNumberFromString (@hundred,"100", @set)
Print("Enter Starting amount  ")
s1=Input()
decNumberFromString (@start, s1, @set)
Print("Enter Interest Rate    ")
s2=Input()
decNumberFromString (@rate, s2, @set)
Print("Enter Number Of Years  ")
s3=Input()
decNumberFromString (@years, s3, @set)
If (set\status & #DEC_Errors)
  PrintN("Invalid input")
  Print("press return key to end")
  Input()
  CloseConsole()
  End
EndIf
decNumberDivide(@rate, @rate, @hundred, @set)  ; rate=rate/100
decNumberAdd(@rate, @rate, @one, @set)         ; rate=rate+1
decNumberPower(@rate, @rate, @years, @set)     ; rate=rate^years
decNumberMultiply(@total, @rate, @start, @set) ; total=rate*start
decNumberRescale(@total, @total, @mtwo, @set)  ; two digits please
If (set\status & #DEC_Errors)
  set\status = set\status & #DEC_Errors        ; keep only errors
  *errmsg = decContextStatusToString(@set)  
  PrintN("Result could not be calculated ")
  PrintN(PeekS(*errmsg))
  Print("press return key to end")
  Input()
  CloseConsole()
  End
EndIf
decNumberToString (@total, *buffer)
PrintN(s1+" dollars at "+s2+"% interest rate for "+s3+" years "+" => "+PeekS(*buffer,-1,#PB_Ascii)+" dollars")

decimal128FromNumber (nq, total, @set)
decimal128ToString (@nq, *buffer)
PrintN(PeekS(*buffer,-1,#PB_Ascii))

Print("press return key to end")
Input()
CloseConsole()

Re: decNumber pbi

Posted: Sun Feb 12, 2017 12:50 pm
by jack
example3.pb
try entering non-numeric input

Code: Select all

OpenConsole()
ConsoleTitle("Calculate Compound Interest")

;/* ------------------------------------------------------------------ */
;/* Decimal Number Library Demonstration program                       */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2001.  All rights reserved.         */
;/* ----------------------------------------------------------------+- */
;/*                                                 right margin -->|  */

;// example3.c -- calculate compound interest, passive checking
;// Arguments are investment, rate (%), And years

;-----------------------------------------------------------------------
;the rounding default is initially set to #DEC_ROUND_HALF_EVEN
;but you can change the rounding mode to any of the following after initializing.
;for example:
;decContextDefault (@set, #DEC_INIT_BASE)  ; initialize
;set\rounding = #DEC_ROUND_UP

;#DEC_ROUND_CEILING             ;/* round towards +infinity         */
;#DEC_ROUND_UP                  ;/* round away from 0               */
;#DEC_ROUND_HALF_UP             ;/* 0.5 rounds up                   */
;#DEC_ROUND_HALF_EVEN           ;/* 0.5 rounds to nearest even      */
;#DEC_ROUND_HALF_DOWN           ;/* 0.5 rounds down                 */
;#DEC_ROUND_DOWN                ;/* round towards 0 (truncate)      */
;#DEC_ROUND_FLOOR               ;/* round towards -infinity         */
;#DEC_ROUND_05UP                ;/* round for reround               */
;#DEC_ROUND_MAX                 ;/* Enumeration must be less than this     */
;------------------------------------------------------------------------

;you need to set the next constant before including any decNumber includes
#DECNUMDIGITS = 38                         ; work with up to 38 digits


XIncludeFile "decNumber.pbi"
XIncludeFile "decQuad.pbi"                ;only needed if working with decQuad

Define.decNumber one, mtwo, hundred, zero       ; constants
Define.decNumber start, rate, years       ; parameters
Define.decNumber total                    ; result
Define.decContext set                     ; working context
Define.s s1, s2, s3
Define.decQuad nq

*buffer = AllocateMemory(#DECNUMDIGITS+16) ; conversion buffer
*errmsg=AllocateMemory(80)

decContextDefault (@set, #DEC_INIT_BASE)  ; initialize
set\traps = 0                             ; no traps
set\digits = 25                           ; precision 25
decNumberFromString (@one,      "1", @set); set constants
decNumberFromString (@mtwo,    "-2", @set)
decNumberFromString (@hundred,"100", @set)

Repeat
  Print("Enter Starting amount  ")
  s1=Input()
  set\Status=0
  decNumberFromString (@start, s1, @set)
  If (set\Status & #DEC_Errors)
    PrintN("Invalid input")
  EndIf
Until (set\Status & #DEC_Errors)=0

Repeat
  Print("Enter Interest Rate    ")
  s2=Input()
  set\Status=0
  decNumberFromString (@rate, s2, @set)
  If (set\Status & #DEC_Errors)
    PrintN("Invalid input")
  EndIf
Until (set\Status & #DEC_Errors)=0

Repeat
  Print("Enter Number Of Years  ")
  s3=Input()
  set\Status=0
  decNumberFromString (@years, s3, @set)
  If (set\Status & #DEC_Errors)
    PrintN("Invalid input")
  EndIf
Until (set\Status & #DEC_Errors)=0

decNumberDivide(@rate, @rate, @hundred, @set)  ; rate=rate/100
decNumberAdd(@rate, @rate, @one, @set)         ; rate=rate+1
decNumberPower(@rate, @rate, @years, @set)     ; rate=rate^years
decNumberMultiply(@total, @rate, @start, @set) ; total=rate*start
decNumberRescale(@total, @total, @mtwo, @set)  ; two digits please
CompilerIf 0
If (set\Status & #DEC_Errors)
  set\Status = set\Status & #DEC_Errors        ; keep only errors
  *errmsg = decContextStatusToString(@set)  
  PrintN("Result could not be calculated ")
  PrintN(PeekS(*errmsg,-1,#PB_Ascii))
  Print("press return key to end")
  Input()
  CloseConsole()
  End
EndIf
CompilerEndIf
decNumberToString (@total, *buffer)
PrintN(s1+" dollars at "+s2+"% interest rate for "+s3+" years "+" => "+PeekS(*buffer,-1,#PB_Ascii)+" dollars")

decQuadFromNumber (nq, total, @set)
decQuadToString (@nq, *buffer)
PrintN("conversion from decNumber to decQuad "+ PeekS(*buffer,-1,#PB_Ascii))

*buffer=decNumberVersion()
PrintN("version "+PeekS(*buffer,-1,#PB_Ascii))

Print("press return key to end")
Input()
CloseConsole()

Re: decNumber pbi

Posted: Sun Feb 12, 2017 8:27 pm
by jack
example6.pb

Code: Select all

OpenConsole()
ConsoleTitle("calculate compound interest, using Packed Decimal")

;/* ------------------------------------------------------------------ */
;/* Decimal Number Library Demonstration program                       */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2001.  All rights reserved.         */
;/* ----------------------------------------------------------------+- */
;/*                                                 right margin -->|  */

;// example6.c -- calculate compound interest, using Packed Decimal
;// Values are investment, rate (%), and years

XIncludeFile "decPacked.pbi"             ;// base number library

;  { ;// excerpt for User's Guide starts here--------------------------|
  Define.decNumber one, mtwo, hundred;                   ;// constants
  Define.decNumber start, rate, years;                   ;// parameters
  Define.decNumber total;                                ;// result
  Define.decContext set;                                 ;// working context

  Dim startpack.uint8_t(3)
      startpack(0)=$01:startpack(1)= $00:startpack(2)= $00:startpack(3)= $0C ;// investment=100000
  startscale.int32_t =0;
  Dim ratepack.uint8_t(1):ratepack(0)=$06:ratepack(1)=$5C                    ;// rate=6.5%
  ratescale.int32_t =1;
  Dim yearspack.uint8_t(1):yearspack(0)=$02:yearspack(1)=$0C                 ;// years=20
  yearsscale.int32_t =0;
  Dim respack.uint8_t (15);                                                  ;// result, packed
  resscale.int32_t ;                                                         ;// ..
  ;Dim hexes.c(49);                                                           ;// for packed->hex
  i.i;                                                                       ;// counter
  *buffer = AllocateMemory(#DECNUMDIGITS+16) ; conversion buffer

  decContextDefault(@set, #DEC_INIT_BASE);         ;// initialize
  set\traps=0;                                     ;// no traps
  set\digits=25;                                   ;// precision 25
  decNumberFromString(@one,       "1", @set);     ;// set constants
  decNumberFromString(@mtwo,     "-2", @set);
  decNumberFromString(@hundred, "100", @set);

  decPackedToNumber(@startpack(0), ArraySize(startpack())+1, @startscale, @start);
  decPackedToNumber(@ratepack(0),  ArraySize(ratepack())+1,  @ratescale,  @rate);
  decPackedToNumber(@yearspack(0), ArraySize(yearspack())+1, @yearsscale, @years);

  decNumberDivide(@rate, @rate, @hundred, @set);  ;// rate=rate/100
  decNumberAdd(@rate, @rate, @one, @set);         ;// rate=rate+1
  decNumberPower(@rate, @rate, @years, @set);     ;// rate=rate^years
  decNumberMultiply(@total, @rate, @start, @set); ;// total=rate*start
  decNumberRescale(@total, @total, @mtwo, @set);  ;// two digits please

  decPackedFromNumber(@respack(0), ArraySize(respack())+1, @resscale, @total);

  ;// lay out the total as sixteen hexadecimal pairs
  For i=0 To 15
    Print(RSet(Hex(respack(i)),2,"0")+" ")
  Next
  PrintN(" resscale = "+Str(resscale))
  decNumberToString (@total, *buffer)
  PrintN(PeekS(*buffer,-1,#PB_Ascii))
  Print("press return key to end")
  Input()
CloseConsole()

Re: decNumber pbi

Posted: Sun Feb 12, 2017 8:30 pm
by jack
corrected a dumb mistake in decContext.pbi, had the macro uint8_t return a Character type which of course does not work in Unicode.