Precision numbers...

Hello, with the following code :

a = rndn(100,1);
print meanc(a-meanc(a));

returns something like :

2.2204460e-017

What should I do to get 0 ???

Thanks,

Guillaume Monarcha

2 Answers



0



PS : I use GAUSS ENGINE 13



0



You change the format of your print statements by using the format command. Here is a basic example:

a = rndn(100,1);

format /rd 8,3;
print meanc(a - meanc(a));

This will return:

  0.000

The first input to format, in this case /rd, tells GAUSS to:

  1. r - right format the printed output
  2. d - print the data as a decimal

The second input to format, in this case 8,3, tells GAUSS to:

  1. 8 - give each printed number enough space for 8 characters
  2. 3 - print out 3 decimal places
  3. If you wanted to print numbers that were left formatted using scientific notation rather than decimal format and wanted to print 4 decimals, you could enter:

    format /le 8,4;
    print meanc(a - meanc(a));
    

    This will return something like:

    2.2204e-17
    

    Besides the d and e options, you can also use the z option. This will use either decimal or scientific notation, whichever is more concise. It will also suppress trailing zeros. Here is a link to another post describing this.

aptech

1,773

Your Answer

2 Answers

0

PS : I use GAUSS ENGINE 13

0

You change the format of your print statements by using the format command. Here is a basic example:

a = rndn(100,1);

format /rd 8,3;
print meanc(a - meanc(a));

This will return:

  0.000

The first input to format, in this case /rd, tells GAUSS to:

  1. r - right format the printed output
  2. d - print the data as a decimal

The second input to format, in this case 8,3, tells GAUSS to:

  1. 8 - give each printed number enough space for 8 characters
  2. 3 - print out 3 decimal places
  3. If you wanted to print numbers that were left formatted using scientific notation rather than decimal format and wanted to print 4 decimals, you could enter:

    format /le 8,4;
    print meanc(a - meanc(a));
    

    This will return something like:

    2.2204e-17
    

    Besides the d and e options, you can also use the z option. This will use either decimal or scientific notation, whichever is more concise. It will also suppress trailing zeros. Here is a link to another post describing this.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.