* Bug 14660 fixed: dec2base was not uint64 ready. 29/21029/6
Stéphane MOTTELET [Thu, 4 Jul 2019 21:24:05 +0000 (23:24 +0200)]
https://bugzilla.scilab.org/show_bug.cgi?id=14660

Change-Id: I7ea342ca26a054b88e34d79f7fe594c3ce1ae108

scilab/CHANGES.md
scilab/modules/elementary_functions/Makefile.am
scilab/modules/elementary_functions/Makefile.in
scilab/modules/elementary_functions/includes/elem_func_gw.hxx
scilab/modules/elementary_functions/includes/gw_elementary_functions.h
scilab/modules/elementary_functions/sci_gateway/c/sci_dec2base.c [deleted file]
scilab/modules/elementary_functions/sci_gateway/cpp/elem_func_gw/elem_func_gw.vcxproj
scilab/modules/elementary_functions/sci_gateway/cpp/elem_func_gw/elem_func_gw.vcxproj.filters
scilab/modules/elementary_functions/sci_gateway/cpp/sci_dec2base.cpp [new file with mode: 0644]
scilab/modules/elementary_functions/tests/nonreg_tests/bug_14660.tst [new file with mode: 0644]

index 4828be8..b9fe168 100644 (file)
@@ -313,6 +313,7 @@ Bug Fixes
 * [#14610](https://bugzilla.scilab.org/14610): `x = ric_desc(H,E)` always yielded an error. [x1,x2,residual] = ric_desc(..) returned a wrong `residual` value.
 * [#14642](https://bugzilla.scilab.org/14642): No more "\r" carriage return with printf.
 * [#14655](https://bugzilla.scilab.org/14655): `bitset` worked only element-wise, without accepting mixed scalar and array inputs.
+* [#14660](https://bugzilla.scilab.org/14660): `dec2base` was 53-bit limited by double and not uint64 ready
 * [#14734](https://bugzilla.scilab.org/14734): The `simulated_annealing` module was out of the `optimization` one.
 * [#14735](https://bugzilla.scilab.org/14735): The `genetic_algorithms` module was out of the `optimization` one.
 * [#14738](https://bugzilla.scilab.org14738): `hist3d` was not actually an histogram function. It is renamed `bar3d`.
index 1b0bc32..874d220 100644 (file)
@@ -279,8 +279,7 @@ ELEMENTARIES_FUNCTIONS_FORTRAN_SOURCES = \
 GATEWAY_C_SOURCES = \
     sci_gateway/c/sci_number_properties.c \
     sci_gateway/c/sci_testmatrix.c \
-    sci_gateway/c/sci_isequalbitwise.c \
-    sci_gateway/c/sci_dec2base.c
+    sci_gateway/c/sci_isequalbitwise.c
 
 GATEWAY_CXX_SOURCES =  \
     sci_gateway/cpp/sci_isequal.cpp \
@@ -335,11 +334,12 @@ GATEWAY_CXX_SOURCES =  \
     sci_gateway/cpp/sci_sqrt.cpp \
     sci_gateway/cpp/sci_issquare.cpp \
     sci_gateway/cpp/sci_linspace.cpp \
-    sci_gateway/cpp/sci_isvector.cpp\
-    sci_gateway/cpp/sci_nearfloat.cpp\
-    sci_gateway/cpp/sci_permute.cpp\
-    sci_gateway/cpp/sci_bitstring.cpp\
-    sci_gateway/cpp/sci_base2dec.cpp    
+    sci_gateway/cpp/sci_isvector.cpp \
+    sci_gateway/cpp/sci_nearfloat.cpp \
+    sci_gateway/cpp/sci_permute.cpp \
+    sci_gateway/cpp/sci_bitstring.cpp \
+    sci_gateway/cpp/sci_base2dec.cpp \
+    sci_gateway/cpp/sci_dec2base.cpp    
 
 EISPACK_SOURCES = src/fortran/eispack/balbak.f
 
index 74b17fd..bb4f4eb 100644 (file)
@@ -354,8 +354,7 @@ libscielementary_functions_la_DEPENDENCIES =  \
        libscielementary_functions-algo.la $(am__DEPENDENCIES_1)
 am__objects_7 = sci_gateway/c/libscielementary_functions_la-sci_number_properties.lo \
        sci_gateway/c/libscielementary_functions_la-sci_testmatrix.lo \
-       sci_gateway/c/libscielementary_functions_la-sci_isequalbitwise.lo \
-       sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo
+       sci_gateway/c/libscielementary_functions_la-sci_isequalbitwise.lo
 am__objects_8 =  \
        sci_gateway/cpp/libscielementary_functions_la-sci_isequal.lo \
        sci_gateway/cpp/libscielementary_functions_la-elem_func_gw.lo \
@@ -413,7 +412,8 @@ am__objects_8 =  \
        sci_gateway/cpp/libscielementary_functions_la-sci_nearfloat.lo \
        sci_gateway/cpp/libscielementary_functions_la-sci_permute.lo \
        sci_gateway/cpp/libscielementary_functions_la-sci_bitstring.lo \
-       sci_gateway/cpp/libscielementary_functions_la-sci_base2dec.lo
+       sci_gateway/cpp/libscielementary_functions_la-sci_base2dec.lo \
+       sci_gateway/cpp/libscielementary_functions_la-sci_dec2base.lo
 am_libscielementary_functions_la_OBJECTS = $(am__objects_7) \
        $(am__objects_8)
 libscielementary_functions_la_OBJECTS =  \
@@ -436,8 +436,7 @@ am__v_at_1 =
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/modules/core/includes
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
 am__maybe_remake_depfiles = depfiles
-am__depfiles_remade = sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo \
-       sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo \
+am__depfiles_remade = sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo \
        sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo \
        sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_testmatrix.Plo \
        sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-elem_func_gw.Plo \
@@ -457,6 +456,7 @@ am__depfiles_remade = sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_
        sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cosh.Plo \
        sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cumprod.Plo \
        sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cumsum.Plo \
+       sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo \
        sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_diag.Plo \
        sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dsearch.Plo \
        sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_exp.Plo \
@@ -1207,8 +1207,7 @@ ELEMENTARIES_FUNCTIONS_FORTRAN_SOURCES = \
 GATEWAY_C_SOURCES = \
     sci_gateway/c/sci_number_properties.c \
     sci_gateway/c/sci_testmatrix.c \
-    sci_gateway/c/sci_isequalbitwise.c \
-    sci_gateway/c/sci_dec2base.c
+    sci_gateway/c/sci_isequalbitwise.c
 
 GATEWAY_CXX_SOURCES = \
     sci_gateway/cpp/sci_isequal.cpp \
@@ -1263,11 +1262,12 @@ GATEWAY_CXX_SOURCES = \
     sci_gateway/cpp/sci_sqrt.cpp \
     sci_gateway/cpp/sci_issquare.cpp \
     sci_gateway/cpp/sci_linspace.cpp \
-    sci_gateway/cpp/sci_isvector.cpp\
-    sci_gateway/cpp/sci_nearfloat.cpp\
-    sci_gateway/cpp/sci_permute.cpp\
-    sci_gateway/cpp/sci_bitstring.cpp\
-    sci_gateway/cpp/sci_base2dec.cpp    
+    sci_gateway/cpp/sci_isvector.cpp \
+    sci_gateway/cpp/sci_nearfloat.cpp \
+    sci_gateway/cpp/sci_permute.cpp \
+    sci_gateway/cpp/sci_bitstring.cpp \
+    sci_gateway/cpp/sci_base2dec.cpp \
+    sci_gateway/cpp/sci_dec2base.cpp    
 
 EISPACK_SOURCES = src/fortran/eispack/balbak.f
 
@@ -2079,9 +2079,6 @@ sci_gateway/c/libscielementary_functions_la-sci_testmatrix.lo:  \
 sci_gateway/c/libscielementary_functions_la-sci_isequalbitwise.lo:  \
        sci_gateway/c/$(am__dirstamp) \
        sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
-sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo:  \
-       sci_gateway/c/$(am__dirstamp) \
-       sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/cpp/$(am__dirstamp):
        @$(MKDIR_P) sci_gateway/cpp
        @: > sci_gateway/cpp/$(am__dirstamp)
@@ -2259,6 +2256,9 @@ sci_gateway/cpp/libscielementary_functions_la-sci_bitstring.lo:  \
 sci_gateway/cpp/libscielementary_functions_la-sci_base2dec.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscielementary_functions_la-sci_dec2base.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscielementary_functions.la: $(libscielementary_functions_la_OBJECTS) $(libscielementary_functions_la_DEPENDENCIES) $(EXTRA_libscielementary_functions_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(CXXLINK) $(am_libscielementary_functions_la_rpath) $(libscielementary_functions_la_OBJECTS) $(libscielementary_functions_la_LIBADD) $(LIBS)
@@ -2285,7 +2285,6 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_testmatrix.Plo@am__quote@ # am--include-marker
@@ -2306,6 +2305,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cosh.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cumprod.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cumsum.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_diag.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dsearch.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_exp.Plo@am__quote@ # am--include-marker
@@ -2752,13 +2752,6 @@ sci_gateway/c/libscielementary_functions_la-sci_isequalbitwise.lo: sci_gateway/c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscielementary_functions_la-sci_isequalbitwise.lo `test -f 'sci_gateway/c/sci_isequalbitwise.c' || echo '$(srcdir)/'`sci_gateway/c/sci_isequalbitwise.c
 
-sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo: sci_gateway/c/sci_dec2base.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Tpo -c -o sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo `test -f 'sci_gateway/c/sci_dec2base.c' || echo '$(srcdir)/'`sci_gateway/c/sci_dec2base.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Tpo sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/sci_dec2base.c' object='sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo `test -f 'sci_gateway/c/sci_dec2base.c' || echo '$(srcdir)/'`sci_gateway/c/sci_dec2base.c
-
 .cpp.o:
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@@ -3252,6 +3245,13 @@ sci_gateway/cpp/libscielementary_functions_la-sci_base2dec.lo: sci_gateway/cpp/s
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscielementary_functions_la-sci_base2dec.lo `test -f 'sci_gateway/cpp/sci_base2dec.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_base2dec.cpp
 
+sci_gateway/cpp/libscielementary_functions_la-sci_dec2base.lo: sci_gateway/cpp/sci_dec2base.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscielementary_functions_la-sci_dec2base.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Tpo -c -o sci_gateway/cpp/libscielementary_functions_la-sci_dec2base.lo `test -f 'sci_gateway/cpp/sci_dec2base.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_dec2base.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Tpo sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_dec2base.cpp' object='sci_gateway/cpp/libscielementary_functions_la-sci_dec2base.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscielementary_functions_la-sci_dec2base.lo `test -f 'sci_gateway/cpp/sci_dec2base.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_dec2base.cpp
+
 .f.o:
        $(AM_V_F77)$(F77COMPILE) -c -o $@ $<
 
@@ -3462,8 +3462,7 @@ clean-am: clean-generic clean-libtool clean-local \
        clean-noinstLTLIBRARIES clean-pkglibLTLIBRARIES mostlyclean-am
 
 distclean: distclean-am
-               -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo
-       -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo
+               -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_testmatrix.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-elem_func_gw.Plo
@@ -3483,6 +3482,7 @@ distclean: distclean-am
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cosh.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cumprod.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cumsum.Plo
+       -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_diag.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dsearch.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_exp.Plo
@@ -3623,8 +3623,7 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-               -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo
-       -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo
+               -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_testmatrix.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-elem_func_gw.Plo
@@ -3644,6 +3643,7 @@ maintainer-clean: maintainer-clean-am
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cosh.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cumprod.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_cumsum.Plo
+       -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_diag.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_dsearch.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-sci_exp.Plo
index 4eb2a01..a0f267f 100644 (file)
@@ -57,6 +57,7 @@ CPP_GATEWAY_PROTOTYPE(sci_cos);
 CPP_GATEWAY_PROTOTYPE(sci_cosh);
 CPP_GATEWAY_PROTOTYPE(sci_cumprod);
 CPP_GATEWAY_PROTOTYPE(sci_cumsum);
+CPP_GATEWAY_PROTOTYPE(sci_dec2base);
 CPP_GATEWAY_PROTOTYPE(sci_diag);
 CPP_GATEWAY_PROTOTYPE(sci_dsearch);
 CPP_GATEWAY_PROTOTYPE(sci_exp);
index 62fef97..4ce76cd 100644 (file)
@@ -67,7 +67,7 @@ STACK_GATEWAY_PROTOTYPE(sci_testmatrix);
 //STACK_GATEWAY_PROTOTYPE(sci_tril);
 //STACK_GATEWAY_PROTOTYPE(sci_triu);
 //STACK_GATEWAY_PROTOTYPE(sci_base2dec);
-STACK_GATEWAY_PROTOTYPE(sci_dec2base);
+//STACK_GATEWAY_PROTOTYPE(sci_dec2base);
 //STACK_GATEWAY_PROTOTYPE(sci_log10);
 //C_GATEWAY_PROTOTYPE(sci_isvector);
 C_GATEWAY_PROTOTYPE(sci_issquare);
diff --git a/scilab/modules/elementary_functions/sci_gateway/c/sci_dec2base.c b/scilab/modules/elementary_functions/sci_gateway/c/sci_dec2base.c
deleted file mode 100644 (file)
index 6e2e943..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2011 - DIGITEO - Allan CORNET
- *
- * Copyright (C) 2012 - 2016 - Scilab Enterprises
- *
- * This file is hereby licensed under the terms of the GNU GPL v2.0,
- * pursuant to article 5.3.4 of the CeCILL v.2.1.
- * This file was originally licensed under the terms of the CeCILL v2.1,
- * and continues to be available under such terms.
- * For more information, see the COPYING file which you should have received
- * along with this program.
- *
- */
-/*--------------------------------------------------------------------------*/
-#include <math.h>
-#include "gw_elementary_functions.h"
-#include "sci_malloc.h"
-#include "api_scilab.h"
-#include "Scierror.h"
-#include "localization.h"
-#include "convertbase.h"
-#include "freeArrayOfString.h"
-/*--------------------------------------------------------------------------*/
-int sci_dec2base(char *fname, void* pvApiCtx)
-{
-    SciErr sciErr;
-    int *piAddressVarOne = NULL;
-    int *piAddressVarTwo = NULL;
-    int m = 0, n = 0;
-
-    double *dValues = NULL;
-    char **convertedValues = NULL;
-    unsigned int iBaseUsed = 0;
-    double dBaseUsed = 0.;
-    unsigned int nbDigits = 0;
-    error_convertbase err = ERROR_CONVERTBASE_NOK;
-
-    CheckInputArgument(pvApiCtx, 2, 3);
-    CheckOutputArgument(pvApiCtx, 0, 1);
-
-    if (nbInputArgument(pvApiCtx) == 3)
-    {
-        double dParamThree = 0.;
-        unsigned int iParamThree = 0;
-        int *piAddressVarThree = NULL;
-        sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddressVarThree);
-        if (sciErr.iErr)
-        {
-            printError(&sciErr, 0);
-            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
-            return 1;
-        }
-
-        if (!isDoubleType(pvApiCtx, piAddressVarThree))
-        {
-            Scierror(999, _("%s: Wrong type for input argument #%d: A scalar integer value expected.\n"), fname, 3);
-            return 1;
-        }
-
-        if (!isScalar(pvApiCtx, piAddressVarThree))
-        {
-            Scierror(999, _("%s: Wrong size for input argument #%d: A scalar integer value expected.\n"), fname, 3);
-            return 1;
-        }
-
-        if (getScalarDouble(pvApiCtx, piAddressVarThree, &dParamThree) != 0)
-        {
-            Scierror(999, _("%s: No more memory.\n"), fname);
-            return 1;
-        }
-
-        iParamThree = (unsigned int)dParamThree;
-
-        if (dParamThree != (double)iParamThree)
-        {
-            Scierror(999, _("%s: Wrong value for input argument #%d: An integer value expected.\n"), fname, 3);
-            return 1;
-        }
-
-        nbDigits = iParamThree;
-    }
-
-    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
-        return 1;
-    }
-
-    if (!isDoubleType(pvApiCtx, piAddressVarTwo))
-    {
-        Scierror(999, _("%s: Wrong type for input argument #%d: An integer value expected.\n"), fname, 2);
-        return 1;
-    }
-
-    if (!isScalar(pvApiCtx, piAddressVarTwo))
-    {
-        Scierror(999, _("%s: Wrong size for input argument #%d.\n"), fname, 2);
-        return 1;
-    }
-
-    if (getScalarDouble(pvApiCtx, piAddressVarTwo, &dBaseUsed) != 0)
-    {
-        Scierror(999, _("%s: No more memory.\n"), fname);
-        return 1;
-    }
-
-    iBaseUsed = (unsigned int)dBaseUsed;
-    if (dBaseUsed != (double)iBaseUsed)
-    {
-        Scierror(999, _("%s: Wrong value for input argument #%d: An integer value expected.\n"), fname, 2);
-        return 1;
-    }
-
-    if (iBaseUsed < 2 || iBaseUsed > 36)
-    {
-        Scierror(999, _("%s: Wrong value for input argument #%d: Must be between %d and %d."), fname, 2, 2, 36);
-        return 1;
-    }
-
-    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
-        return 1;
-    }
-
-    if (isEmptyMatrix(pvApiCtx, piAddressVarOne))
-    {
-        if (createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1) != 0)
-        {
-            Scierror(999, _("%s: No more memory.\n"), fname);
-            return 1;
-        }
-        else
-        {
-            AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
-            ReturnArguments(pvApiCtx);
-            return 0;
-        }
-    }
-
-    if (!isDoubleType(pvApiCtx, piAddressVarOne))
-    {
-        Scierror(999, _("%s: Wrong type for input argument #%d: A matrix of integer value expected.\n"), fname, 1);
-        return 1;
-    }
-
-    if (isVarComplex(pvApiCtx, piAddressVarOne))
-    {
-        Scierror(999, _("%s: Wrong type for input argument #%d: A matrix of integer value expected.\n"), fname, 1);
-        return 1;
-    }
-
-    sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarOne, &m, &n , &dValues);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
-        return 1;
-    }
-
-    convertedValues = convertMatrixOfDec2Base(dValues, m * n, iBaseUsed, nbDigits, &err);
-    if ((err != ERROR_CONVERTBASE_OK) || (convertedValues == NULL))
-    {
-        freeArrayOfString(convertedValues, m * n);
-        convertedValues = NULL;
-
-        switch (err)
-        {
-            case ERROR_CONVERTBASE_NOT_INTEGER_VALUE:
-                Scierror(999, _("%s: Wrong value(s) for input argument #%d: A matrix of positive integer values expected.\n"), fname, 1);
-                return 1;
-
-            case ERROR_CONVERTBASE_NOT_IN_INTERVAL:
-                Scierror(999, _("%s: Wrong value for input argument #%d: Must be between 0 and 2^52.\n"), fname, 1);
-                return 1;
-
-            case ERROR_CONVERTBASE_ALLOCATION:
-                Scierror(999, _("%s: No more memory.\n"), fname);
-                return 1;
-
-            case ERROR_CONVERTBASE_NOK:
-            default:
-                Scierror(999, _("%s: Wrong value for input argument #%d: cannot convert value(s).\n"), fname, 1);
-                return 1;
-        }
-    }
-
-    sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m, n, (char const * const*) convertedValues);
-    freeArrayOfString(convertedValues, m * n);
-    convertedValues = NULL;
-
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Memory allocation error.\n"), fname);
-        return 1;
-    }
-
-    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
-    ReturnArguments(pvApiCtx);
-    return 0;
-}
-/*--------------------------------------------------------------------------*/
index d86f481..a4a7cf6 100644 (file)
@@ -203,7 +203,6 @@ lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACH
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\src\cpp\getmode.cpp" />
-    <ClCompile Include="..\..\c\sci_dec2base.c" />
     <ClCompile Include="..\..\c\sci_isequalbitwise.c" />
     <ClCompile Include="..\..\c\sci_number_properties.c" />
     <ClCompile Include="..\..\c\sci_testmatrix.c" />
@@ -224,6 +223,7 @@ lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACH
     <ClCompile Include="..\sci_cosh.cpp" />
     <ClCompile Include="..\sci_cumprod.cpp" />
     <ClCompile Include="..\sci_cumsum.cpp" />
+    <ClCompile Include="..\sci_dec2base.cpp" />
     <ClCompile Include="..\sci_diag.cpp" />
     <ClCompile Include="..\sci_dsearch.cpp" />
     <ClCompile Include="..\sci_exp.cpp" />
index 34b5d4c..2357b0c 100644 (file)
     <ClCompile Include="..\sci_isequal.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\c\sci_dec2base.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\sci_prod.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\sci_base2dec.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\sci_dec2base.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\includes\elem_func_gw.hxx">
diff --git a/scilab/modules/elementary_functions/sci_gateway/cpp/sci_dec2base.cpp b/scilab/modules/elementary_functions/sci_gateway/cpp/sci_dec2base.cpp
new file mode 100644 (file)
index 0000000..57b14c4
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2019 - Stéphane MOTTELET
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+/*--------------------------------------------------------------------------*/
+
+#include <algorithm>
+#include "elem_func_gw.hxx"
+#include "function.hxx"
+#include "double.hxx"
+#include "int.hxx"
+#include "string.hxx"
+#include "overload.hxx"
+
+extern "C"
+{
+#include "Scierror.h"
+}
+
+template <typename T> types::String* dectobase(T *_pIn, int iParam[]);
+
+/*--------------------------------------------------------------------------*/
+types::Function::ReturnValue sci_dec2base(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    int iParam[2] = { 0, 0 };
+    types::String* pOut = NULL;
+
+    if (in.size() < 2 || in.size() > 3)
+    {
+        Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), "dec2base", 2, 3);
+        return types::Function::Error;
+    }
+
+    if (_iRetCount > 1)
+    {
+        Scierror(77, _("%s: Wrong number of output argument(s): %d expected.\n"), "dec2base", 1);
+        return types::Function::Error;
+    }
+
+    for (int i = 1; i < in.size(); i++)
+    {
+        if (in[i]->isDouble() == false)
+        {
+            Scierror(999, _("%s: Wrong value for input argument #%d: A positive integer expected.\n"), "dec2base", i + 1);
+            return types::Function::Error;
+        }
+        else
+        {
+            types::Double *pDbl = in[i]->getAs<types::Double>();
+            if (pDbl->isComplex() == true || pDbl->isScalar() == false ||
+                pDbl->get(0) != trunc(pDbl->get(0)) || pDbl->get(0) < 0)
+            {
+                Scierror(999, _("%s: Wrong value for input argument #%d: A positive integer expected.\n"), "dec2base", i + 1);
+                return types::Function::Error;
+            }
+
+            iParam[i - 1] = (int)pDbl->get(0);
+        }
+    }
+
+    if (iParam[0] < 2 || iParam[0] > 36)
+    {
+        Scierror(999, _("%s: Wrong value for input argument #%d: Must be between %d and %d."), "dec2base", 2, 2, 36);
+        return types::Function::Error;
+    }
+
+    if (in[0]->isDouble())
+    {
+        types::Double* pDblIn = in[0]->getAs<types::Double>();
+
+        if (pDblIn->isEmpty())
+        {
+            out.push_back(types::Double::Empty());
+            return types::Function::OK;
+        }
+
+        if (pDblIn->isComplex())
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A matrix of integer value expected.\n"), "dec2base", 1);
+            return types::Function::Error;
+        }
+
+        for (int i = 0; i < pDblIn->getSize(); i++)
+        {
+            if (trunc(pDblIn->get(i)) != pDblIn->get(i))
+            {
+                Scierror(999, _("%s: Wrong value(s) for input argument #%d: A matrix of positive integer values expected.\n"), "dec2base", 1);
+                return types::Function::Error;
+            }
+
+            if (pDblIn->get(i) > pow(2, 53))
+            {
+                Scierror(999, _("%s: Wrong value for input argument #%d: Must be between 0 and 2^53.\n"), "dec2base", 1);
+                return types::Function::Error;
+            }
+        }
+
+        pOut = dectobase(in[0]->getAs<types::Double>(), iParam);
+    }
+    else if (in[0]->isInt())
+    {
+        switch (in[0]->getType())
+        {
+        case types::InternalType::ScilabInt8:
+            pOut = dectobase(in[0]->getAs<types::Int8>(), iParam);
+            break;
+        case types::InternalType::ScilabUInt8:
+            pOut = dectobase(in[0]->getAs<types::UInt8>(), iParam);
+            break;
+        case types::InternalType::ScilabInt16:
+            pOut = dectobase(in[0]->getAs<types::Int16>(), iParam);
+            break;
+        case types::InternalType::ScilabUInt16:
+            pOut = dectobase(in[0]->getAs<types::UInt16>(), iParam);
+            break;
+        case types::InternalType::ScilabInt32:
+            pOut = dectobase(in[0]->getAs<types::Int32>(), iParam);
+            break;
+        case types::InternalType::ScilabUInt32:
+            pOut = dectobase(in[0]->getAs<types::UInt32>(), iParam);
+            break;
+        case types::InternalType::ScilabInt64:
+            pOut = dectobase(in[0]->getAs<types::Int64>(), iParam);
+            break;
+        case types::InternalType::ScilabUInt64:
+            pOut = dectobase(in[0]->getAs<types::UInt64>(), iParam);
+            break;
+        default: // should not happen
+            break;
+        }
+    }
+    else
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d : A real or integer matrix expected.\n"), "dec2base", 2);
+    }
+
+    if (pOut == NULL)
+    {
+        return types::Function::Error;
+    }
+
+    out.push_back(pOut);
+    return types::Function::OK;
+}
+
+template <typename T> types::String* dectobase(T *_pIn, int iParam[])
+{
+    int iBaseUsed = iParam[0];
+    int iNbDigits = iParam[1];
+    unsigned long long int n;
+    const char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    types::String* _pOut = new types::String(_pIn->getDims(), _pIn->getDimsArray());
+
+    if (iBaseUsed == 2)
+    {
+        // for binary conversion default iNbDigits is the largest needed number of bits among matrix terms
+        unsigned long long iMax;
+        iMax = (unsigned long long) *(std::max_element(_pIn->get(), _pIn->get() + _pIn->getSize()));
+        int iDepth = 0;
+        // iDepth is equal to trunc(log2(iMax))+1 i.e. number of needed bits
+        while (iMax)
+        {
+            iMax >>= 1;
+            iDepth++;
+        }
+
+        iNbDigits = iNbDigits > iDepth ? iNbDigits : iDepth;
+    }
+
+    for (int i = 0; i < _pIn->getSize(); i++)
+    {
+        if (_pIn->get(i) < 0)
+        {
+            Scierror(999, _("%s: Wrong value(s) for input argument #%d: A matrix of positive integer values expected.\n"), "dec2base", 1);
+            _pOut->killMe();
+            return NULL;
+        }
+
+        std::string s;
+        s.reserve(65);
+        n = (unsigned long long int) _pIn->get(i);
+
+        // digits are obtained in reverse order
+        do
+        {
+            s.append(1, digits[n % iBaseUsed]); // store and get next digit
+        } while ((n /= iBaseUsed) > 0); // "delete" it
+
+        s.append(std::max(iNbDigits - (int)s.length(), 0), '0');
+        reverse(s.begin(), s.end());
+        _pOut->set(i, s.data());
+    }
+    return _pOut;
+}
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14660.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14660.tst
new file mode 100644 (file)
index 0000000..6b46eef
--- /dev/null
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - Stéphane MOTTELET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 14660 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/14660
+//
+// <-- Short Description -->
+// dec2base is 53-bit limited by double and not uint64 ready
+
+assert_checkequal(dec2base(uint64(%inf),36),"3W5E11264SGSF");
+assert_checkequal(dec2base(uint64(%inf),2),"1111111111111111111111111111111111111111111111111111111111111111");
+msg = msprintf(_("%s: Wrong value for input argument #%d: Must be between 0 and 2^53.\n"), "dec2base", 1);
+assert_checkerror("dec2base(2^53+2,2)", msg);
\ No newline at end of file