I am working with a lot of small probability numbers, which are stored as real variables. It seems that DOORS will only display up to 6 digits of precision past the decimal point. Is there a way for me to extend this to many more digits of precision?
|
Re: real number decimal precision
I don't know what you are doing exactly with these numbers but if you can use strings, you can just move more digits to the left side of the decimal then physically place the period. It is set up to display percentages and is most percise for numbers below 100%.
real a = 12345
real b = 67890
real c = 100000000000.0
real d = (a*c)/b
string e = d""
int i
int j
int k
for(i=0;i<(length e);i++)
{
if(e[i]"" == ".")
break
}
j = length e[(i+1):] + 11 // Number of 0's in c + 1
k = length e - j
e = e[0:k]"."e[(k+1):(i-1)]""e[(i+1):]"%"
print e
|
Re: real number decimal precision AAI Services, Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
Re: real number decimal precision Golly, its ugly but it works. There may be significant string-table waste here, but I doubt you will convert 100s of 1000s of real numbers. The '17' calibration is accurate but hokey, I cannot think of another way to insure that the printed number does not have any more precision than the original real number. The '50' parameter is arbitrary and hokey also. That seems like a reasonable limit on the number of whole or decimal digits in the final string. Someone more familiar with 'real' numbers and especially how they are typically implemented on computers may want to provide a better mechanism for doing this. Not seen in this set of outputs but in earlier versions, was awkward rounding errors introduced by the function. In one case I had "1.113" converted to "1.1129999999999999". What's next, I suppose, is figuring out how to convert a real number to scientific format, "1234e-3". >Louie Attachments attachment_14243552_Driver_fStringOfReal.dxl |
Re: real number decimal precision llandale - Wed Apr 22 13:56:40 EDT 2009 --excel or --vba |
Re: real number decimal precision |
Re: real number decimal precision SystemAdmin - Mon May 04 17:05:33 EDT 2009 I suppose another way to do this would be to multiply the number by some huge power of 10, convert to a string, then manipulate the string to put the decimal point in the right place. >Louie |
Re: real number decimal precision llandale - Wed Apr 22 13:56:40 EDT 2009 real rInput = (1.0) * (1.00000000000000014)
This does not work properly. it displays 1.0000000000000002 Not sure why |
Re: real number decimal precision jester76 - Sat Oct 05 23:06:41 EDT 2013 real rInput = (1.0) * (1.00000000000000014)
This does not work properly. it displays 1.0000000000000002 Not sure why It is not a trivial problem to convert real to a string. I posted my real formatting library code Here. |
Re: real number decimal precision Adamarla - Mon Oct 07 04:33:40 EDT 2013 It is not a trivial problem to convert real to a string. I posted my real formatting library code Here. Hello, How do I increase the precision to 16 dgits on your script? thanks |
Re: real number decimal precision jester76 - Mon Oct 07 09:12:50 EDT 2013 Hello, How do I increase the precision to 16 dgits on your script? thanks It already converts to the maximum precision. My guess is you are suffering loss due to your calculations. Real number format does NOT store exact representations of all numbers. Can you post an example of what you want vs what you get? -Adam |
Re: real number decimal precision Adamarla - Mon Oct 07 04:33:40 EDT 2013 It is not a trivial problem to convert real to a string. I posted my real formatting library code Here. Here is an example of what I am dealing with. real rInput = (1.0) * (1.00000000000000014)
This does not work properly. it displays 1.0000000000000002 I should be getting 1.00000000000000014 Thanks for your help |
Re: real number decimal precision Adamarla - Mon Oct 07 10:27:53 EDT 2013 It already converts to the maximum precision. My guess is you are suffering loss due to your calculations. Real number format does NOT store exact representations of all numbers. Can you post an example of what you want vs what you get? -Adam real rInput = (1.0) * (1.00000000000000014)
This does not work properly. it displays 1.0000000000000002 while I should be getting 1.0000000000000001
thanks for your help |
Re: real number decimal precision jester76 - Mon Oct 07 11:27:48 EDT 2013 real rInput = (1.0) * (1.00000000000000014)
This does not work properly. it displays 1.0000000000000002 while I should be getting 1.0000000000000001
thanks for your help The real format does not support the level of precision you want.
1.0000000000000001 is stored as 1 and therefore retrieved as 1. 1.00000000000000014 is stored as 1.0000000000000002 and therefore retrieved as 1.0000000000000002. Calculations may result in precision loss. Read up on the floating point binary64 (Double precision) format to get a better understanding of what is possible. -Adam
|
Re: real number decimal precision jester76 - Mon Oct 07 11:25:46 EDT 2013 Here is an example of what I am dealing with. real rInput = (1.0) * (1.00000000000000014)
This does not work properly. it displays 1.0000000000000002 I should be getting 1.00000000000000014 Thanks for your help Your number is stressing the limits of real precision. Not sure any function can deal with that. |
Re: real number decimal precision Adamarla - Mon Oct 07 12:59:54 EDT 2013 The real format does not support the level of precision you want.
1.0000000000000001 is stored as 1 and therefore retrieved as 1. 1.00000000000000014 is stored as 1.0000000000000002 and therefore retrieved as 1.0000000000000002. Calculations may result in precision loss. Read up on the floating point binary64 (Double precision) format to get a better understanding of what is possible. -Adam
Adam,
The article says it can do up 17 digits. Am I missing anything?
-Jester |
Re: real number decimal precision jester76 - Tue Oct 08 13:38:21 EDT 2013 Adam,
The article says it can do up 17 digits. Am I missing anything?
-Jester yes.
1.0000000000000002, the smallest number > 1
|