rounding in quantlib

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

rounding in quantlib

Pavan Shah-2
Hello,
I am trying to round time to expiry using quantlib.  
How do i round  a double to an int?
i know i could force type conversion in c++ but that will round a 3.67 to 3 I believe.
i don't want that.

Can someone provide an example please with the proper class and method?

thanks
Pavan

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: rounding in quantlib

Oleg Goldshmidt
On Thu, Jan 10, 2013 at 9:12 PM, Pavan Shah <[hidden email]> wrote:
> Hello,
> I am trying to round time to expiry using quantlib.
> How do i round  a double to an int?
> i know i could force type conversion in c++ but that will round a 3.67 to 3
> I believe.
> i don't want that.

Add 0.5 before casting.

--
Oleg Goldshmidt | [hidden email]

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: rounding in quantlib

Pavan Shah-2
yes ofcourse that would do it.


On Thu, Jan 10, 2013 at 11:21 AM, Oleg Goldshmidt <[hidden email]> wrote:
On Thu, Jan 10, 2013 at 9:12 PM, Pavan Shah <[hidden email]> wrote:
> Hello,
> I am trying to round time to expiry using quantlib.
> How do i round  a double to an int?
> i know i could force type conversion in c++ but that will round a 3.67 to 3
> I believe.
> i don't want that.

Add 0.5 before casting.

--
Oleg Goldshmidt | [hidden email]


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users