Hi
i need to do operation in ruby with 36 bit float exactly.
is there a class who can do it?
Can we modify constant parameter of class float(DIG,MANT_DIG) ?
thank you
Hi
i need to do operation in ruby with 36 bit float exactly.
is there a class who can do it?
Can we modify constant parameter of class float(DIG,MANT_DIG) ?
thank you
Mat Pfa wrote in post #1164106:
i need to do operation in ruby with 36 bit float exactly.
is there a class who can do it?
You can use BigDecimal:
irb(main):001:0> x = BigDecimal(“1”) / 3
=> #<BigDecimal:6006d8048,‘0.3333333333 33333333E0’,18(36)>
irb(main):002:0> puts x
0.333333333333333333E0
=> nil
irb(main):003:0> sprintf("%.36f", x)
=> “0.333333333333333314829616256247390993”
irb(main):004:0> sprintf("%.36f", x).length
=> 38
Can we modify constant parameter of class float(DIG,MANT_DIG) ?
What do you mean by that?
Cheers
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs