0

I'm trying to cast a decimal real to double precision and it has the following behavior:

select 2.2::real::double precision;

Outputs:

2.20000004768372 (double precision)

How can I make it output the following:

2.2 (double precision)

Thank you

NewK
  • 343
  • 3
  • 21

1 Answers1

0

Thank you a_horse_with_no_name, nice reading.

I solved my problem by casting to text before converting to double:

select 2.2::real::text::double precision;

That outputs:

2.2 (double precision)

And for future reference, if you must use double precision, you shouldn't mix it with real.

Community
  • 1
  • 1
NewK
  • 343
  • 3
  • 21