1

Input value to the procedure (Float) = 999999.98999999999

Inside the procedure, I am converting the float to VARCHAR(15), While conversion the value become 1000000 but is need an Output = 999999.99.

Not able to use Substring(), Charindex().

Please help me.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Venkatesh R
  • 515
  • 1
  • 10
  • 27
  • 2
    Possible duplicate of [Why Are Floating Point Numbers Inaccurate?](http://stackoverflow.com/questions/21895756/why-are-floating-point-numbers-inaccurate) – Idos Dec 10 '15 at 10:56
  • No the share link is different from query. The link did not answer my query. Thanks for your information but I am sorry. – Venkatesh R Dec 11 '15 at 12:57

1 Answers1

2

You can use STR() function for that:

declare @floatValue float = 999999.98999999999
declare @varcharValue varchar(15) = STR(@floatValue, 12, 2)

or CONVERT()

CONVERT (VARCHAR(15), @floatValue, 128)
Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116