513{
516
517 if (*_number ==
__T(
'\0') || iswspace((wint_t)*_number)) {
518 throw new NumericConvertException(_number, _base, 0);
519 }
520
521 NumericConvertException::Error error = NumericConvertException::NoError;
522 errno = 0;
523 wchar_t* endptr =
NULL;
524 long long n = wcstoll(_number, &endptr, _base);
525 if (errno == ERANGE) {
526 if (LLONG_MIN == n) {
527 error = NumericConvertException::Underflow;
528 }
529 else if (LLONG_MAX == n) {
530 error = NumericConvertException::Overflow;
531 }
532
533 if (NumericConvertException::NoError != error) {
534 throw new NumericConvertException(
535 error,
536 _number,
537 _base
538 );
539 }
540 }
541
542 if ((endptr && *endptr != '\0') || errno == EINVAL) {
543 throw new NumericConvertException(
544 _number,
545 _base,
546 endptr ? (endptr - _number) : 0
547 );
548 }
549
550 return (int64_t) n;
551}