Java convert float to integer -


I want to do an operation like this: if the given float number is 1.0, 2.0, 3.0, then I save I want them to be an integer (1,2,3) for the database, if they are like 1.1, 2.1, 3.44, then I save them as float. What is the best solution to this problem with the help of java? The type of varchar related field in the database is.

just try int i = (int) f; .

EDIT: I am looking at the point in question. This code can work:

  int i = (int) f; String valToStore = (i == f)? String.valueOf (i): String.valueOf (f);  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -