Skip to Content
avatar image
Former Member

how to Convert the STRING TO FLOAT.

Hi Experts,

Can u suggest me how to write the UDF Function From STRING TO FLOAT.

Thanks & Regards,

Sateesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Aug 13, 2007 at 08:22 PM

    Would it make more sense to use the Float class?

    float return=Float.parseFloat(input);

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 14, 2007 at 09:43 AM

    its working

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 13, 2007 at 05:24 PM

    hi Sateesh,

    It will convert to float

    float return=Double.parseDouble(input);

    or

    float return=Double.valueOf(input).floatValue();

    best,

    Wojciech

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 14, 2007 at 02:39 PM

    Avoid using float in Java, as it leads to round errors.

    Use BigDecimal instead.

    http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html

    BigDecimal big = new BigDecimal("your_string");

    Regards,

    Henrique.

    Add comment
    10|10000 characters needed characters exceeded