Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Casting to quad precision

Status
Not open for further replies.

DaPhil

Technical User
Jun 24, 2011
6
DE
Hi,
I want to get a sqrt from an integer to quad precision. I tried to do this:

integer : i_j
real*16 :: r_hlp

r_hlp = sqrt(i_j)

but the compiler does not cast the integer to quad precision and therefor says that the types are not correct. How do I solve this? Casting to double precision via dble(i_j) is easy, is there a similar for quad precision?
 
I tried this
Code:
[COLOR=#2e8b57][b]integer[/b][/color] :: i
[COLOR=#2e8b57][b]real[/b][/color][COLOR=#804040][b]*[/b][/color][COLOR=#ff00ff]16[/color] :: r_hlp, r_i

i [COLOR=#804040][b]=[/b][/color] [COLOR=#ff00ff]2[/color]
r_i [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]real[/color](i, [COLOR=#ff00ff]16[/color])
[COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'i ='[/color], i, [COLOR=#ff00ff]', r_i = '[/color], r_i

r_hlp [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]sqrt[/color](r_i)
[COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'r_hlp = '[/color], r_hlp
[COLOR=#a020f0]end[/color]
with result
Code:
$ conv_quad
 i = 2 , r_i =  2.
 r_hlp =  1.4142135623730950488016887242096982
 
What exactly do you mean by a quad precision integer? How many bits are you expecting? A normal integer is 32 bits. Are you expecting a number with 128 bits? If you are then it really does depend on whether your compiler supports an integer of that magnitude.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top