locked
limit float data type RRS feed

  • Question

  • User-2060576634 posted

    hello everyone..
    can we limit the float data type to this format: "0.00" in the database?

    Sunday, February 1, 2015 1:32 AM

Answers

  • User1759999623 posted

    It cannot be stored as a float.  You would need to store it as a decimal(15, 2), but this would be a fixed-point number.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 1, 2015 2:48 AM

All replies

  • User1759999623 posted

    A floating point is based on its size: a float (Single) has up to seven decimal digits of precision while a double (Double) has fifteen decimal digits of precision.  The data in your database will reflect that.

    Now, maybe your question is really:  Can I display my float data type as "0.00" when there is less than two significant decimal digits and then only show two decimal digits otherwise?

    Sunday, February 1, 2015 2:21 AM
  • User-2060576634 posted

    I want 33.3333320617676 to be stored as 33.33

    Sunday, February 1, 2015 2:26 AM
  • User1759999623 posted

    It cannot be stored as a float.  You would need to store it as a decimal(15, 2), but this would be a fixed-point number.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 1, 2015 2:48 AM