Round the numbers
Forums › ProRealTime English forum › ProBuilder support › Round the numbers
- This topic has 4 replies, 2 voices, and was last updated 4 years ago by robertogozzi. 
- 
	
		
- 
		
			
				
04/20/2017 at 12:56 PM #32741hi, Could someone please tell me how i get round numbers. I only want 2 numbers after the komma code i have now = 1234a= mashortif mashort<mashort[1] thenDRAWTEXT(" BEAR ■",barindex+0.5,+0.7,SansSerif,Bold,12)coloured(255,0,0)Drawtext("#a#",barindex-Xoffset-1.35,+0.7,SansSerif,Bold,12)coloured(0,0,0)the #a# gives the numbers, but 2 would be enough like 15.06 Thanks in advance rgds John 04/20/2017 at 1:23 PM #32756Hi, To the best of my knowledge, there’s no direct way to specify how many digits after comma, but there’s a way to do it with small extra calculation. The only function available would be round(x) to make a round number (no digits beyond comma) out of a real number x. So my trick is to multiply x by 10^N, round this, and then divide the rounded value by 10^N, N being the number of digits wanted after comma. For example, in your case you would be interested to have N=2 and do: a=round(mashort*100)/100 1 user thanked author for this post.04/20/2017 at 1:53 PM #3276910/05/2021 at 1:54 PM #17907210/05/2021 at 2:18 PM #179081Yes, it's easy now, but back then the second parameter to ROUND () didn't exist. 
- 
		AuthorPosts


 
 

 
		 
		 
		