0

Hi Am developing one application in java and Am using sql server database . I'm inserting values in database in 23.6 but its appending like 23.645464 . is there any method to append after decimal no only one digit. please help me.

Thanks

Raghava Vaddi
  • 31
  • 1
  • 5

2 Answers2

0

how about this in sql server.

SELECT round (cast(23.645464 AS DECIMAL(10,1)),2);
Vishwanath Dalvi
  • 35,388
  • 41
  • 123
  • 155
0

Hey you can try this code in Java file before storing value in database..

For example :

Function call :

float round = Round(num,1);

Definition:

public static float Round(float val, int dec) {
  float p = (float)Math.pow(10,dec);
  val = val * p;
  float tmp = Math.round(val);
  return (float)tmp/p;
  }
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Nirav Valera
  • 420
  • 4
  • 13