~haggai-eran/nux/rtl-rebased

« back to all changes in this revision

Viewing changes to NuxCore/NumberConversion.cpp

  • Committer: Jay Taoko
  • Date: 2011-10-21 22:06:35 UTC
  • mto: This revision was merged to the branch mainline in revision 509.
  • Revision ID: jay.taoko@canonical.com-20111021220635-1tdvncs47hdlfbz1
* Removed custom Nux types: t_u32, t_s32, t_bool, ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2010 Inalogic® Inc.
 
2
 * Copyright 2010 Inalogic� Inc.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify it
5
5
 * under the terms of the GNU Lesser General Public License, as
71
71
    return str;
72
72
  }
73
73
 
74
 
  t_double CharToDouble (const TCHAR *digit)
 
74
  double CharToDouble (const TCHAR *digit)
75
75
  {
76
76
    char *endptr = NULL;
77
77
    NString str = TCHAR_TO_ANSICHAR (digit);
78
78
    errno = 0;
79
 
    t_double ret = std::strtod (str.GetTCharPtr(), &endptr);
80
 
    t_u32 error = errno;
 
79
    double ret = std::strtod (str.GetTCharPtr(), &endptr);
 
80
    unsigned int error = errno;
81
81
 
82
82
    if (error == ERANGE)
83
83
    {
99
99
    return str;
100
100
  }
101
101
 
102
 
  t_s32 CharToInteger (const TCHAR *digit)
 
102
  int CharToInteger (const TCHAR *digit)
103
103
  {
104
104
    NString str = TCHAR_TO_ANSICHAR (digit);
105
 
    t_s64 ret = std::atoi (str.GetTCharPtr() );
 
105
    long long ret = std::atoi (str.GetTCharPtr() );
106
106
    return ret;
107
107
  }
108
108
 
109
 
// convert an hexadecimal string to t_u32
110
 
  t_u32 HexCharToInteger (const TCHAR *s)
 
109
// convert an hexadecimal string to unsigned int
 
110
  unsigned int HexCharToInteger (const TCHAR *s)
111
111
  {
112
112
    int n = 0;         // position in string
113
113
    int m = 0;         // position in digit[] to shift