From: Lou Vanek Date: 2005-12-23T21:26:11+09:00 Subject: Re: formatting BigDecimal#sqrt yeah, it looks right. interesting format variation: minfieldwidth = 22 precision = 16 sprintf "%*.*f", minfieldwidth, precision, BigDecimal.new("66543").sqrt(precision) => " 257.9592991151898786" James Edward Gray II wrote: > On Dec 22, 2005, at 4:04 PM, James Edward Gray II wrote: > >> I'm trying to understand the argument to BigDecimal#sqrt. I figured >> it was for precision and it does seem to affect it, but I can't >> understand the exactly relationship. Can anyone tell me what the >> argument controls and how? > > > Let me try asking my question a different way... Is this the correct > way to get a printable square root with N digits precision (N = 16 in > this example)? > > >> sprintf "%.16f", BigDecimal.new("66543").sqrt(16) > => "257.9592991151890260" > > James Edward Gray II