Numerics.cpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel */
40 /* */
41 /* Utility class to manage the various sorts of numeric conversions required */
42 /* by Rexx. These conversions are all just static methods. */
43 /* */
44 /******************************************************************************/
45 
46 #include "RexxCore.h"
47 #include "Numerics.hpp"
48 #include "NumberStringClass.hpp"
49 #include "IntegerClass.hpp"
50 #include <limits.h>
51 
52 #ifdef __REXX64__
53 const wholenumber_t Numerics::MAX_WHOLENUMBER = __INT64_C(999999999999999999);
54 const wholenumber_t Numerics::MIN_WHOLENUMBER = __INT64_C(-999999999999999999);
55  // the digits setting used internally for function/method arguments to allow
56  // for the full range
57 const size_t Numerics::ARGUMENT_DIGITS = ((size_t)18);
58 // this is the digits setting for full size binary settings
59 const size_t Numerics::SIZE_DIGITS = ((size_t)20);
60 
61 
62 /* Array for valid whole number at various digits settings */
63 /* for value 1-18. */
65  100,
66  1000,
67  10000,
68  100000,
69  1000000,
70  10000000,
71  100000000,
72  1000000000,
73  10000000000,
74  100000000000,
75  1000000000000,
76  10000000000000,
77  100000000000000,
78  1000000000000000,
79  10000000000000000,
80  100000000000000000,
81  1000000000000000000};
82 #else
84 const wholenumber_t Numerics::MIN_WHOLENUMBER = -999999999;
85  // the digits setting used internally for function/method arguments to allow
86  // for the full binary value range
87 const size_t Numerics::ARGUMENT_DIGITS = ((size_t)9);
88 // this is the digits setting for full size binary settings
89 const size_t Numerics::SIZE_DIGITS = ((size_t)10);
90 
91 
92 /* Array for valid whole number at various digits settings */
93 /* for value 1-9. */
95  100,
96  1000,
97  10000,
98  100000,
99  1000000,
100  10000000,
101  100000000,
102  1000000000};
103 #endif
104 
105 const wholenumber_t Numerics::MAX_EXPONENT = 999999999;
106 const wholenumber_t Numerics::MIN_EXPONENT = -999999999;
107 // this is the matching component to a whole number
108 const stringsize_t Numerics::MAX_STRINGSIZE = MAX_WHOLENUMBER;
109  // max numeric digits value for explicit 64-bit conversions
110 const size_t Numerics::DIGITS64 = ((size_t)20);
111 // numeric digits 9 is always the default
112 const size_t Numerics::DEFAULT_DIGITS = ((size_t)9);
113 const bool Numerics::FORM_SCIENTIFIC = false;
114 const bool Numerics::FORM_ENGINEERING = true;
115 
116 const size_t Numerics::DEFAULT_FUZZ = ((size_t)0); /* default numeric fuzz setting */
117  /* default numeric form setting */
119 
122 
123 
125 {
129 }
130 
131 
132 /**
133  * Convert a signed int64 object into the appropriate Rexx
134  * object type.
135  *
136  * @param v The value to convert.
137  *
138  * @return The Rexx object version of this number.
139  */
141 {
142  // in the range for an integer object?
143  if (v <= MAX_WHOLENUMBER && v >= MIN_WHOLENUMBER)
144  {
145  return new_integer((wholenumber_t)v);
146  }
147  // out of range, we need to use a numberstring for this, using the full
148  // allowable digits range
149  return new_numberstringFromInt64(v);
150 }
151 
152 
153 /**
154  * Convert a signed int64 object into the appropriate Rexx
155  * object type.
156  *
157  * @param v The value to convert.
158  *
159  * @return The Rexx object version of this number.
160  */
162 {
163  // in the range for an integer object?
164  if (v <= (uint64_t)MAX_WHOLENUMBER)
165  {
166  return new_integer((stringsize_t)v);
167  }
168  // out of range, we need to use a numberstring for this, using the full
169  // allowable digits range
170  return new_numberstringFromUint64(v);
171 }
172 
173 
174 /**
175  * Convert an signed number value into the appropriate Rexx
176  * object type.
177  *
178  * @param v The value to convert.
179  *
180  * @return The Rexx object version of this number.
181  */
183 {
184  // in the range for an integer object?
185  if (v <= MAX_WHOLENUMBER && v >= MIN_WHOLENUMBER)
186  {
187  return new_integer((wholenumber_t)v);
188  }
189  // out of range, we need to use a numberstring for this, using the full
190  // allowable digits range
192 }
193 
194 
195 /**
196  * Convert an unsigned number value into the appropriate Rexx
197  * object type.
198  *
199  * @param v The value to convert.
200  *
201  * @return The Rexx object version of this number.
202  */
204 {
205  // in the range for an integer object?
206  if (v <= (stringsize_t)MAX_WHOLENUMBER)
207  {
208  return new_integer((stringsize_t)v);
209  }
210  // out of range, we need to use a numberstring for this, using the full
211  // allowable digits range
213 }
214 
215 /**
216  * Convert an object into a whole number value.
217  *
218  * @param source The source object.
219  * @param result The returned converted value.
220  * @param maxValue The maximum range value for the target.
221  * @param minValue The minimum range value for this number.
222  *
223  * @return true if the number converted properly, false for any
224  * conversion errors.
225  */
227 {
228  // is this an integer value (very common)
229  if (isInteger(source))
230  {
231  result = ((RexxInteger *)source)->wholeNumber();
232  return result <= maxValue && result >= minValue ? true : false;
233  }
234  else
235  {
236  // get this as a numberstring (which it might already be)
237  RexxNumberString *nString = source->numberString();
238  // not convertible to number string? get out now
239  if (nString == OREF_NULL)
240  {
241  return false;
242  }
243  int64_t temp;
244 
245  // if not valid or outside of the minimum range, reject this too
246  if (nString->int64Value(&temp, ARGUMENT_DIGITS))
247  {
248  if (temp <= maxValue && temp >= minValue)
249  {
250  result = (wholenumber_t)temp;
251  return true;
252  }
253  }
254  return false;
255  }
256 }
257 
258 /**
259  * Convert an object into a signed integer value.
260  *
261  * @param source The source object.
262  * @param result The returned converted value.
263  * @param maxValue The maximum range value for the target.
264  * @param minValue The minimum range value for this number.
265  *
266  * @return true if the number converted properly, false for any
267  * conversion errors.
268  */
269 bool Numerics::objectToSignedInteger(RexxObject *source, ssize_t &result, ssize_t maxValue, ssize_t minValue)
270 {
271  // is this an integer value (very common)
272  if (isInteger(source))
273  {
274  result = ((RexxInteger *)source)->wholeNumber();
275  return result <= maxValue && result >= minValue ? true : false;
276  }
277  else
278  {
279  // get this as a numberstring (which it might already be)
280  RexxNumberString *nString = source->numberString();
281  // not convertible to number string? get out now
282  if (nString == OREF_NULL)
283  {
284  return false;
285  }
286  int64_t temp;
287 
288  // if not valid or outside of the minimum range, reject this too
289  if (nString->int64Value(&temp, SIZE_DIGITS))
290  {
291  if (temp <= maxValue && temp >= minValue)
292  {
293  result = (wholenumber_t)temp;
294  return true;
295  }
296  }
297  return false;
298  }
299 }
300 
301 
302 /**
303  * Convert an object into an unsigned number value.
304  *
305  * @param source The source object.
306  * @param result The returned converted value.
307  * @param maxValue The maximum range value for the target.
308  *
309  * @return true if the number converted properly, false for any
310  * conversion errors.
311  */
313 {
314  // is this an integer value (very common)
315  if (isInteger(source))
316  {
317  // reject any signed values.
318  if (((RexxInteger *)source)->wholeNumber() < 0)
319  {
320  return false;
321  }
322 
323  result = ((RexxInteger *)source)->stringSize();
324  return result <= maxValue ? true : false;
325  }
326  else
327  {
328  // get this as a numberstring (which it might already be)
329  RexxNumberString *nString = source->numberString();
330  // not convertible to number string? get out now
331  if (nString == OREF_NULL)
332  {
333  return false;
334  }
335  uint64_t temp;
336 
337  // if not valid or outside of the minimum range, reject this too
338  if (nString->unsignedInt64Value(&temp, ARGUMENT_DIGITS))
339  {
340  if ( temp <= maxValue )
341  {
342  result = (stringsize_t)temp;
343  return true;
344  }
345  }
346  return false;
347  }
348 }
349 
350 
351 /**
352  * Convert an object into an unsigned number value.
353  *
354  * @param source The source object.
355  * @param result The returned converted value.
356  * @param maxValue The maximum range value for the target.
357  *
358  * @return true if the number converted properly, false for any
359  * conversion errors.
360  */
361 bool Numerics::objectToUnsignedInteger(RexxObject *source, size_t &result, size_t maxValue)
362 {
363  // is this an integer value (very common)
364  if (isInteger(source))
365  {
366  // reject any signed values.
367  if (((RexxInteger *)source)->wholeNumber() < 0)
368  {
369  return false;
370  }
371 
372  result = ((RexxInteger *)source)->stringSize();
373  return result <= maxValue ? true : false;
374  }
375  else
376  {
377  // get this as a numberstring (which it might already be)
378  RexxNumberString *nString = source->numberString();
379  // not convertible to number string? get out now
380  if (nString == OREF_NULL)
381  {
382  return false;
383  }
384  uint64_t temp;
385 
386  // if not valid or outside of the minimum range, reject this too
387  if (nString->unsignedInt64Value(&temp, SIZE_DIGITS))
388  {
389  if ( temp <= maxValue )
390  {
391  result = (stringsize_t)temp;
392  return true;
393  }
394  }
395  return false;
396  }
397 }
398 
399 
400 /**
401  * Convert an object into a signed int64 value.
402  *
403  * @param source The source object.
404  * @param result The returned converted value.
405  *
406  * @return true if the number converted properly, false for any
407  * conversion errors.
408  */
410 /******************************************************************************/
411 /* Function: Convert a Rexx object into a numeric value within the specified */
412 /* value range. If the value is not convertable to an integer value or is */
413 /* outside of the specified range, false is returned. */
414 /******************************************************************************/
415 {
416  // is this an integer value (very common)
417  if (isInteger(source))
418  {
419  result = ((RexxInteger *)source)->wholeNumber();
420  return true;
421  }
422  else
423  {
424  // get this as a numberstring (which it might already be)
425  RexxNumberString *nString = source->numberString();
426  // not convertible to number string? get out now
427  if (nString == OREF_NULL)
428  {
429  return false;
430  }
431 
432  // if not a valid whole number, reject this too
433  return nString->int64Value(&result, DIGITS64);
434  }
435 }
436 
437 
438 /**
439  * Validate that an object can be converted to an int64_t value
440  *
441  * @param source The source object.
442  *
443  * @return Returns an object that has been validated as a valid
444  * int64_t value and can be passed to a native routine. Returns
445  * null if this object is not valid.
446  */
448 {
449  // is this an integer value (very common)
450  if (isInteger(source))
451  {
452  return source;
453  }
454  else
455  {
456  // get this as a numberstring (which it might already be)
457  RexxNumberString *nString = source->numberString();
458  // not convertible to number string? get out now
459  if (nString == OREF_NULL)
460  {
461  return OREF_NULL;
462  }
463 
464  int64_t result;
465  // if not a valid whole number, reject this too
466  if (!nString->int64Value(&result, DIGITS64)) {
467  return OREF_NULL;
468  }
469  return nString;
470  }
471 }
472 
473 
474 /**
475  * Convert an object into an unsigned int64 value.
476  *
477  * @param source The source object.
478  * @param result The returned converted value.
479  *
480  * @return true if the number converted properly, false for any
481  * conversion errors.
482  */
484 /******************************************************************************/
485 /* Function: Convert a Rexx object into a numeric value within the specified */
486 /* value range. If the value is not convertable to an integer value or is */
487 /* outside of the specified range, false is returned. */
488 /******************************************************************************/
489 {
490  // is this an integer value (very common)
491  if (isInteger(source))
492  {
493  // reject any signed values.
494  if (((RexxInteger *)source)->wholeNumber() < 0)
495  {
496  return false;
497  }
498  result = ((RexxInteger *)source)->stringSize();
499  return true;
500  }
501  else
502  {
503  // get this as a numberstring (which it might already be)
504  RexxNumberString *nString = source->numberString();
505  // not convertible to number string? get out now
506  if (nString == OREF_NULL)
507  {
508  return false;
509  }
510 
511  // if not a valid whole number, reject this too
512  return nString->unsignedInt64Value(&result, DIGITS64);
513  }
514 }
515 
516 
517 /**
518  * Convert an object into an uintptr_t values. Used for values
519  * that are numbers masking as pointers.
520  *
521  * @param source The source object.
522  * @param result The returned value.
523  *
524  * @return true if this converted, false for any conversion failures.
525  */
527 {
528  stringsize_t temp;
529  // if it didn't convert for the range, give a failure back
531  {
532  return false;
533  }
534  // ok, this worked
535  result = (uintptr_t)temp;
536  return true;
537 }
538 
539 
540 /**
541  * Convert an object into an intptr_t values. Used for values
542  * that are numbers masking as pointers.
543  *
544  * @param source The source object.
545  * @param result The returned value.
546  *
547  * @return true if this converted, false for any conversion failures.
548  */
550 {
551  wholenumber_t temp;
552  // if it didn't convert for the range, give a failure back
554  {
555  return false;
556  }
557  // ok, this worked
558  result = (intptr_t)temp;
559  return true;
560 }
561 
562 
563 /**
564  * Do portable formatting of a wholenumber value into an ascii
565  * string.
566  *
567  * @param integer The value to convert.
568  * @param dest The location to store the formatted string.
569  *
570  * @return The length of the converted number.
571  */
573 {
574  // zero? this is pretty easy
575  if (integer == 0)
576  {
577  strcpy(dest, "0");
578  return 1;
579  }
580 
581  size_t sign = 0;
582  // we convert this directly because portable numeric-to-ascii routines
583  // don't really exist for the various 32/64 bit values.
584  char buffer[24];
585  size_t index = sizeof(buffer);
586 
587  // negative number? copy a negative sign, and take the abs value
588  if (integer < 0)
589  {
590  *dest++ = '-';
591  // work from an unsigned version that can hold all of the digits
592  // we need to use a version we can negate first, then add the
593  // digit back in
594  size_t working = (size_t)(-(integer + 1));
595  working++; // undoes the +1 above
596  sign = 1; // added in to the length
597 
598  while (working > 0)
599  {
600  // get the digit and reduce the size of the integer
601  int digit = (int)(working % 10);
602  working = working / 10;
603  // store the digit
604  buffer[--index] = digit + '0';
605  }
606  }
607  else
608  {
609  while (integer > 0)
610  {
611  // get the digit and reduce the size of the integer
612  int digit = (int)(integer % 10) + '0';
613  integer = integer / 10;
614  // store the digit
615  buffer[--index] = digit;
616  }
617  }
618 
619  // copy into the buffer and set the length
620  stringsize_t length = sizeof(buffer) - index;
621  memcpy(dest, &buffer[index], length);
622  // make sure we have a terminating null
623  dest[length] = '\0';
624  return length + sign;
625 }
626 
627 
628 /**
629  * Do portable formatting of a wholenumber value into
630  * numberstring format.
631  *
632  * @param integer The value to convert.
633  * @param dest The location to store the formatted string.
634  *
635  * @return The length of the converted number.
636  */
638 {
639  // zero? this is pretty easy
640  if (integer == 0)
641  {
642  *dest = '\0';
643  return 1;
644  }
645 
646  // we convert this directly because portable numeric-to-ascii routines
647  // don't really exist for the various 32/64 bit values.
648  char buffer[24];
649  size_t index = sizeof(buffer);
650 
651  // negative number? copy a negative sign, and take the abs value
652  if (integer < 0)
653  {
654  // work from an unsigned version that can hold all of the digits
655  // we need to use a version we can negate first, then add the
656  // digit back in
657  size_t working = (size_t)(-(integer + 1));
658  working++; // undoes the +1 above
659 
660  while (working > 0)
661  {
662  // get the digit and reduce the size of the integer
663  int digit = (int)(working % 10);
664  working = working / 10;
665  // store the digit
666  buffer[--index] = digit;
667  }
668  }
669  else
670  {
671  while (integer > 0)
672  {
673  // get the digit and reduce the size of the integer
674  int digit = (int)(integer % 10);
675  integer = integer / 10;
676  // store the digit
677  buffer[--index] = digit;
678  }
679  }
680 
681  // copy into the buffer and set the length
682  stringsize_t length = sizeof(buffer) - index;
683  memcpy(dest, &buffer[index], length);
684  // make sure we have a terminating null
685  dest[length] = '\0';
686  return length;
687 }
688 
689 /**
690  * Do portable formatting of a stringsize value into an ascii
691  * string.
692  *
693  * @param integer The value to convert.
694  * @param dest The location to store the formatted string.
695  *
696  * @return The length of the converted number.
697  */
699 {
700  // zero? this is pretty easy
701  if (integer == 0)
702  {
703  strcpy((char *)dest, "0");
704  return 1;
705  }
706 
707  // we convert this directly because portable numeric-to-ascii routines
708  // don't really exist for the various 32/64 bit values.
709  char buffer[24];
710  size_t index = sizeof(buffer);
711 
712  while (integer > 0)
713  {
714  // get the digit and reduce the size of the integer
715  int digit = (int)(integer % 10) + '0';
716  integer = integer / 10;
717  // store the digit
718  buffer[--index] = digit;
719  }
720 
721  // copy into the buffer and set the length
722  stringsize_t length = sizeof(buffer) - index;
723  memcpy(dest, &buffer[index], length);
724  // make sure we have a terminating null
725  dest[length] = '\0';
726  return length;
727 }
728 
729 
730 /**
731  * Do portable formatting of an int64_t value into an ascii
732  * string.
733  *
734  * @param integer The value to convert.
735  * @param dest The location to store the formatted string.
736  *
737  * @return The length of the converted number.
738  */
740 {
741  // zero? this is pretty easy
742  if (integer == 0)
743  {
744  strcpy((char *)dest, "0");
745  return 1;
746  }
747 
748  // we convert this directly because portable numeric-to-ascii routines
749  // don't really exist for the various 32/64 bit values.
750  char buffer[32];
751  size_t index = sizeof(buffer);
752  size_t sign = 0;
753 
754  // negative number? copy a negative sign, and take the abs value
755  if (integer < 0)
756  {
757  *dest++ = '-';
758  // work from an unsigned version that can hold all of the digits
759  // we need to use a version we can negate first, then add the
760  // digit back in
761  uint64_t working = (uint64_t)(-(integer + 1));
762  working++; // undoes the +1 above
763  sign = 1; // added in to the length
764 
765  while (working > 0)
766  {
767  // get the digit and reduce the size of the integer
768  int digit = (int)(working % 10);
769  working = working / 10;
770  // store the digit
771  buffer[--index] = digit + '0';
772  }
773  }
774  else
775  {
776  while (integer > 0)
777  {
778  // get the digit and reduce the size of the integer
779  int digit = (int)(integer % 10) + '0';
780  integer = integer / 10;
781  // store the digit
782  buffer[--index] = digit;
783  }
784  }
785 
786  // copy into the buffer and set the length
787  stringsize_t length = sizeof(buffer) - index;
788  memcpy(dest, &buffer[index], length);
789  // make sure we have a terminating null
790  dest[length] = '\0';
791  return length + sign;
792 }
793 
794 
795 /**
796  * Do portable formatting of a uint64_t value into an ascii
797  * string.
798  *
799  * @param integer The value to convert.
800  * @param dest The location to store the formatted string.
801  *
802  * @return The length of the converted number.
803  */
805 {
806  // zero? this is pretty easy
807  if (integer == 0)
808  {
809  strcpy(dest, "0");
810  return 1;
811  }
812 
813  // we convert this directly because portable numeric-to-ascii routines
814  // don't really exist for the various 32/64 bit values.
815  char buffer[32];
816  size_t index = sizeof(buffer);
817 
818  while (integer > 0)
819  {
820  // get the digit and reduce the size of the integer
821  int digit = (int)(integer % 10) + '0';
822  integer = integer / 10;
823  // store the digit
824  buffer[--index] = digit;
825  }
826 
827  // copy into the buffer and set the length
828  stringsize_t length = sizeof(buffer) - index;
829  memcpy(dest, &buffer[index], length);
830  // make sure we have a terminating null
831  dest[length] = '\0';
832  return length;
833 }
834 
835 
836 /**
837  * Convert an unsigned ptr value into the appropriate Rexx
838  * object type.
839  *
840  * @param v The value to convert.
841  *
842  * @return The Rexx object version of this number.
843  */
845 {
846  // in the range for an integer object?
847  if (v <= (uintptr_t)MAX_WHOLENUMBER)
848  {
849  return new_integer((wholenumber_t)v);
850  }
851  // out of range, we need to use a numberstring for this, using the full
852  // allowable digits range. Note that this assumes we maintain the connection
853  // that a wholenumber_t is the same size as an intptr_t.
855 }
856 
857 
858 /**
859  * Convert an signed ptr value into the appropriate Rexx object
860  * type.
861  *
862  * @param v The value to convert.
863  *
864  * @return The Rexx object version of this number.
865  */
867 {
868  // in the range for an integer object?
870  {
871  return new_integer((wholenumber_t)v);
872  }
873  // out of range, we need to use a numberstring for this, using the full
874  // allowable digits range. Note that this assumes we maintain the connection
875  // that a wholenumber_t is the same size as an intptr_t.
877 }
878 
879 
880 /**
881  * Format a pointer into a string value using a consistent
882  * formatting style.
883  *
884  * @param p The pointer valut to format.
885  *
886  * @return The pointer as a string value in the format 0xnnnnnnnn.
887  */
889 {
890  // some platforms render a null pointer as "0x(nil)". We want this
891  // to be just zero, so force it that way
892  if (p == 0)
893  {
894  return new_string("0x0");
895  }
896 
897  // format this into a chracter string
898  char temp[32];
899  // unfortunately, the formation of %p is not consistent across platforms.
900  // We first format this directly, and if the value does not be
901  snprintf(temp, sizeof temp, "%p", p);
902  if (temp[1] != 'x')
903  {
904  snprintf(temp, sizeof temp, "0x%p", p);
905  }
906  return new_string(temp);
907 
908 }
RexxInteger * new_integer(wholenumber_t v)
RexxNumberString * new_numberstringFromWholenumber(wholenumber_t n)
RexxNumberString * new_numberstringFromUint64(uint64_t n)
RexxNumberString * new_numberstringFromInt64(int64_t n)
RexxNumberString * new_numberstringFromStringsize(stringsize_t n)
bool isInteger(RexxObject *o)
Definition: RexxCore.h:282
#define OREF_NULL
Definition: RexxCore.h:61
RexxString * new_string(const char *s, stringsize_t l)
ssize_t integer(RexxObject *obj, const char *errorMessage)
Definition: TextClass.cpp:289
static const wholenumber_t MIN_WHOLENUMBER
Definition: Numerics.hpp:63
static bool objectToUintptr(RexxObject *source, uintptr_t &result)
Definition: Numerics.cpp:526
static RexxObject * stringsizeToObject(stringsize_t v)
Definition: Numerics.cpp:203
static const wholenumber_t MIN_EXPONENT
Definition: Numerics.hpp:65
static size_t formatStringSize(stringsize_t integer, char *dest)
Definition: Numerics.cpp:698
static const size_t DIGITS64
Definition: Numerics.hpp:75
static const wholenumber_t MAX_WHOLENUMBER
Definition: Numerics.hpp:62
static const wholenumber_t validMaxWhole[]
Definition: Numerics.hpp:83
static RexxObject * uintptrToObject(uintptr_t v)
Definition: Numerics.cpp:844
static RexxObject * int64Object(RexxObject *source)
Definition: Numerics.cpp:447
static const bool DEFAULT_FORM
Definition: Numerics.hpp:81
static const wholenumber_t MAX_EXPONENT
Definition: Numerics.hpp:64
static NumericSettings * settings
Definition: Numerics.hpp:142
static size_t formatUnsignedInt64(uint64_t integer, char *dest)
Definition: Numerics.cpp:804
static bool objectToUnsignedInt64(RexxObject *o, uint64_t &result)
Definition: Numerics.cpp:483
static size_t formatInt64(int64_t integer, char *dest)
Definition: Numerics.cpp:739
static const size_t MAX_STRINGSIZE
Definition: Numerics.hpp:72
static bool objectToUnsignedInteger(RexxObject *o, size_t &result, size_t max)
Definition: Numerics.cpp:361
static bool objectToWholeNumber(RexxObject *o, wholenumber_t &result, wholenumber_t max, wholenumber_t min)
Definition: Numerics.cpp:226
static RexxObject * int64ToObject(int64_t v)
Definition: Numerics.cpp:140
static const bool FORM_SCIENTIFIC
Definition: Numerics.hpp:76
static const size_t DEFAULT_FUZZ
Definition: Numerics.hpp:79
static NumericSettings defaultSettings
Definition: Numerics.hpp:143
static const bool FORM_ENGINEERING
Definition: Numerics.hpp:77
static size_t normalizeWholeNumber(wholenumber_t integer, char *dest)
Definition: Numerics.cpp:637
static bool objectToIntptr(RexxObject *source, intptr_t &result)
Definition: Numerics.cpp:549
static RexxObject * wholenumberToObject(wholenumber_t v)
Definition: Numerics.cpp:182
static bool objectToStringSize(RexxObject *o, stringsize_t &result, stringsize_t max)
Definition: Numerics.cpp:312
static bool objectToSignedInteger(RexxObject *o, ssize_t &result, ssize_t max, ssize_t min)
Definition: Numerics.cpp:269
static RexxString * pointerToString(void *)
Definition: Numerics.cpp:888
static RexxObject * intptrToObject(intptr_t v)
Definition: Numerics.cpp:866
static const size_t SIZE_DIGITS
Definition: Numerics.hpp:71
static const size_t ARGUMENT_DIGITS
Definition: Numerics.hpp:68
static size_t formatWholeNumber(wholenumber_t integer, char *dest)
Definition: Numerics.cpp:572
static bool objectToInt64(RexxObject *o, int64_t &result)
Definition: Numerics.cpp:409
static RexxObject * uint64ToObject(uint64_t v)
Definition: Numerics.cpp:161
static const size_t DEFAULT_DIGITS
Definition: Numerics.hpp:66
bool int64Value(int64_t *result, stringsize_t numDigits)
bool unsignedInt64Value(uint64_t *result, stringsize_t numDigits)
RexxNumberString * numberString()
ssize_t wholenumber_t
Definition: rexx.h:230
size_t stringsize_t
Definition: rexx.h:228
#define __INT64_C(c)
#define INTPTR_MIN
UINT_PTR uintptr_t
signed __int64 int64_t
SSIZE_T ssize_t
#define INTPTR_MAX
#define UINTPTR_MAX
INT_PTR intptr_t
unsigned __int64 uint64_t