quantlib has round function?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

quantlib has round function?

刘华
Hi
I want to know if quantlib has function as follow:

double amt = 1235.5678;

amt = function(1235.5678, 2), 2- precision

amt = 1235.57

thks!!!
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

答复: quantlib has round function?

cheng li
Just use

amt = std::round(amt * 100.0) / 100.0;

-----邮件原件-----
发件人: 刘华 [mailto:[hidden email]]
发送时间: 2013年5月27日 15:18
收件人: [hidden email]
主题: [Quantlib-users] quantlib has round function?

Hi
I want to know if quantlib has function as follow:

double amt = 1235.5678;

amt = function(1235.5678, 2), 2- precision

amt = 1235.57

thks!!!
----------------------------------------------------------------------------
--
Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only
SaaS-based application performance monitoring service that delivers powerful
full stack analytics. Optimize and monitor your browser, app, & servers with
just a few lines of code. Try New Relic and get this awesome Nerd Life
shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: 答复: quantlib has round function?

Luigi Ballabio
Or

rounded = ClosestRounding(2)(amt);

in <ql/math/rounding.hpp> you'll also find functions for up-rounding,
down-rounding etc.

Luigi


On Mon, May 27, 2013 at 5:42 PM, Cheng Li <[hidden email]> wrote:

> Just use
>
> amt = std::round(amt * 100.0) / 100.0;
>
> -----邮件原件-----
> 发件人: 刘华 [mailto:[hidden email]]
> 发送时间: 2013年5月27日 15:18
> 收件人: [hidden email]
> 主题: [Quantlib-users] quantlib has round function?
>
> Hi
> I want to know if quantlib has function as follow:
>
> double amt = 1235.5678;
>
> amt = function(1235.5678, 2), 2- precision
>
> amt = 1235.57
>
> thks!!!
> ----------------------------------------------------------------------------
> --
> Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only
> SaaS-based application performance monitoring service that delivers powerful
> full stack analytics. Optimize and monitor your browser, app, & servers with
> just a few lines of code. Try New Relic and get this awesome Nerd Life
> shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users