How to suppress trailing zeros in print statements

0

I would like to suppress trailing zeros in a print statement. For example, I would like this:

```x = { 1.2345, 5.2, 9.86 };
print x;
```

to return:

```    1.2345
5.2
9.86
```

1 Answer

0
accepted

You can accomplish this with the format statement. You need to pass it the flag /rz. The 'r' tells GAUSS to right-justify the print statement and the 'z' tells GAUSS to display whichever is more compact, decimal or scientific notation and to suppress trailing zeros.

```format /rz;
x = { 1.2345, 5.2, 9.86 };
print x;
```

will return the desired output:

```    1.2345
5.2
9.86
```

The format statement can also take inputs for the width which to print each number and the number of digits to print. For example:

```format /rz 10,2;
x = { 1.2345, 5.2, 9.86 };
print x;
```

will display up to 2 digits and the final digit will be 10 spaces to the right of the left margin:

```
1.2
5.2
9.9
```

Whereas:

```format /rz 8,3;
x = { 1.2345, 5.2, 9.86 };
print x;
```

will display up to 3 digits with the final digit 8 spaces from the left margin:

```    1.23
5.2
9.86
```

Your Answer

Tags: asked November 5, 2013

1 Answer

0
accepted

You can accomplish this with the format statement. You need to pass it the flag /rz. The 'r' tells GAUSS to right-justify the print statement and the 'z' tells GAUSS to display whichever is more compact, decimal or scientific notation and to suppress trailing zeros.

```format /rz;
x = { 1.2345, 5.2, 9.86 };
print x;
```

will return the desired output:

```    1.2345
5.2
9.86
```

The format statement can also take inputs for the width which to print each number and the number of digits to print. For example:

```format /rz 10,2;
x = { 1.2345, 5.2, 9.86 };
print x;
```

will display up to 2 digits and the final digit will be 10 spaces to the right of the left margin:

```
1.2
5.2
9.9
```

Whereas:

```format /rz 8,3;
x = { 1.2345, 5.2, 9.86 };
print x;
```

will display up to 3 digits with the final digit 8 spaces from the left margin:

```    1.23
5.2
9.86
```

• Aptech Systems, Inc. Worldwide Headquarters

Address:
Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286

Phone: 360.886.7100
FAX: 360.886.8922

Ready to Get Started?

• Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

• Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

• Want to find out more?

Get a real answer from a real person

• Have a Specific Question?

Get a real answer from a real person

• Need Support?
• Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

• User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!

• Where to Buy

Available across the globe, you can have access to GAUSS no matter where you are.