/* RubyFloat.pmc
 *  Copyright (C) 2001-2003, The Perl Foundation.
 *  SVN Info
 *     $Id: rubyfloat.pmc 17096 2007-02-20 20:20:48Z paultcochrane $
 *  Overview:
 *     These are the vtable functions for the RubyFloat base class
 *  Data Structure and Algorithms:
 *  History:
 *  Notes:
 *  References:
 */

#include "parrot/parrot.h"
#include <assert.h>

#define RUBY_NUMBER_FMT		("%.14g")

pmclass RubyFloat
        extends Float
        does float
        dynpmc
        group ruby_group
        hll Cardinal
        maps Float {

    STRING* get_string () {
        UINTVAL buflen;
        STRING * buff;

        buff = Parrot_sprintf_c(INTERP, "%.12vg",PMC_num_val(SELF));

        buflen = string_length(INTERP,buff);
        while (buflen) {
               if (string_index(INTERP,buff,buflen-1) == '0') {
                       buflen--;
               }
               else {
                       break;
               }
        }

        /* truncate the string */
        buff->strlen = buflen;
        buff->bufused = buflen;
        return buff;
    }

    METHOD PMC* interpret() {
        return SELF;
    }
}


/*
 * Local variables:
 *   c-file-style: "parrot"
 * End:
 * vim: expandtab shiftwidth=4:
 */
