Changeset eccd20e6 in mainline for uspace/lib/posix/stdlib/strtold.c


Ignore:
Timestamp:
2011-07-21T22:34:14Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c6f4681, e478cebf
Parents:
df0956ee (diff), cfbb5d18 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/stdlib/strtold.c

    rdf0956ee reccd20e6  
    3030 * @{
    3131 */
    32 /** @file
     32/** @file Backend for floating point conversions.
    3333 */
    3434
     
    5555#endif
    5656
    57 // TODO: clean up, documentation
     57// TODO: clean up
    5858
    5959// FIXME: ensure it builds and works on all platforms
     
    116116};
    117117
     118/**
     119 * Decides whether the argument is still in range representable by
     120 * long double or not.
     121 *
     122 * @param num Floating point number to be checked.
     123 * @return True if the argument is out of range, false otherwise.
     124 */
    118125static inline bool out_of_range(long double num)
    119126{
     
    127134 * @param base Number to be multiplied.
    128135 * @param exponent Base 5 exponent.
    129  * @return base multiplied by 5**exponent
     136 * @return base multiplied by 5**exponent.
    130137 */
    131138static long double mul_pow5(long double base, int exponent)
     
    173180 * @param base Number to be multiplied.
    174181 * @param exponent Base 2 exponent.
    175  * @return base multiplied by 2**exponent
     182 * @return base multiplied by 2**exponent.
    176183 */
    177184static long double mul_pow2(long double base, int exponent)
     
    212219}
    213220
    214 
     221/**
     222 * Convert decimal string representation of the floating point number.
     223 * Function expects the string pointer to be already pointed at the first
     224 * digit (i.e. leading optional sign was already consumed by the caller).
     225 *
     226 * @param sptr Pointer to the storage of the string pointer. Upon successful
     227 *     conversion, the string pointer is updated to point to the first
     228 *     unrecognized character.
     229 * @return An approximate representation of the input floating-point number.
     230 */
    215231static long double parse_decimal(const char **sptr)
    216232{
     
    315331}
    316332
     333/**
     334 * Derive a hexadecimal digit from its character representation.
     335 *
     336 * @param ch Character representation of the hexadecimal digit.
     337 * @return Digit value represented by an integer.
     338 */
    317339static inline int hex_value(char ch)
    318340{
     
    325347
    326348/**
     349 * Get the count of leading zero bits up to the maximum of 3 zero bits.
     350 *
    327351 * @param val Integer value.
    328352 * @return How many leading zero bits there are. (Maximum is 3)
     
    339363}
    340364
     365/**
     366 * Convert hexadecimal string representation of the floating point number.
     367 * Function expects the string pointer to be already pointed at the first
     368 * digit (i.e. leading optional sign and 0x prefix were already consumed
     369 * by the caller).
     370 *
     371 * @param sptr Pointer to the storage of the string pointer. Upon successful
     372 *     conversion, the string pointer is updated to point to the first
     373 *     unrecognized character.
     374 * @return Representation of the input floating-point number.
     375 */
    341376static long double parse_hexadecimal(const char **sptr)
    342377{
     
    478513 * @param nptr Input string.
    479514 * @param endptr If non-NULL, *endptr is set to the position of the first
    480  *    unrecognized character.
     515 *     unrecognized character.
    481516 * @return An approximate representation of the input floating-point number.
    482517 */
     
    512547               
    513548                if (endptr != NULL) {
    514                         *endptr = (char *) &nptr[i + 3];
    515                 }
    516                 errno = ERANGE;
    517                 return negative ? -0.0l : +0.0l;
     549                        *endptr = (char *) nptr;
     550                }
     551                errno = EINVAL;
     552                return 0;
    518553        }
    519554       
     
    567602/** @}
    568603 */
    569 
Note: See TracChangeset for help on using the changeset viewer.