NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 11-25-2010, 09:44 AM   #1
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default dropping the decimal places?

Howdy,

This should be a fairly simple question. I wish to convert a variable with a decimal to only the integer value before the decimal, for example taking these figures:

4.02
4.24
4.74
3.88
3.34

I wish to convert these to:

4
4
4
3
3

I'd like to be able to compare when the "integer" value changed (in other words using the above example when the variable changed from a value of "4" to "3"...). Thank you in advance.
Burga1 is offline  
Reply With Quote
Old 11-25-2010, 10:00 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Burga1, you can just case them to be an int -

double myDouble = 3.34;
int myInt = (int)myDouble;
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 11-25-2010, 12:00 PM   #3
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for the help!
Burga1 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Show more than 2 decimal places williammanda General Programming 6 03-05-2012 02:00 AM
Decimal Places in Control Box DaveE Version 7 Beta General Questions & Bug Reports 3 10-29-2010 08:22 AM
FX price being truncated to 3 decimal places on chart when it should be 4 places. bluelou Charting 2 08-05-2010 04:03 PM
Is there a way to see 2 decimal places in SMA? gsmaster Charting 1 05-02-2008 12:25 PM
Finding decimal places sbgtrading General Programming 3 11-25-2007 07:29 PM


All times are GMT -6. The time now is 09:08 AM.