![]() |
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
|
|||||||
| Version 7 Beta General Questions & Bug Reports Ask questions here and post bug reports. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jun 2010
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
(1) I'd like to get the last number of decimal (for example : if hh = 1.3257, I'd like to register an integer of 7). (2) I've done the following but found out that after casting into an integer( vb ), the last digit was not the same and ended up I was getting the wrong value ( vc ). May I know where I've made mistakes? Thanks! if(Bars.FirstBarOfSession) { hh = High[0]; } double va = hh*10000; int vb = (int) va; int vc = vb % 10; Print(hh.ToString("0.0000") + " " + va.ToString("00000") + " " + vb.ToString("00000") + " " + vc.ToString("0")); |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello m. khalid,
This is more C# related so beyond our scope of support. To get the integer portion of a double value, you may want to use Math.Truncate() rather than casting it as integer. http://msdn.microsoft.com/en-us/libr...(v=VS.90).aspx
Ryan M
NinjaTrader Customer Service |
|
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help to convert from double to int | safetrading | Indicator Development | 6 | 09-30-2010 09:46 PM |
| ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double s | adamus | Version 7 Beta General Questions & Bug Reports | 9 | 06-28-2010 04:16 PM |
| Double into int | Gepetto | Automated Trading | 5 | 11-18-2009 11:16 AM |
| casting a string to an int | blarouche | Indicator Development | 1 | 07-10-2009 11:14 AM |
| double to int ? | zoltran | Indicator Development | 3 | 03-14-2007 01:51 AM |