I try to have all calculation and data-formation issues squared away before applying display formatting. So, from R:SYNTAX, this might be helpful:
(BRND(arg1,arg2,arg3))

Rounds REAL, DOUBLE, or CURRENCY data to a specific number of decimal places and allows specification of the number of significant digits to return. Arg1 is the value to be rounded. Arg2 is the number of significant digits to return, and Arg3 is the precision. The precision is specified as a decimal number, for example, .01 rounds to two decimal places.

In the following example, the value of vresult is 1234.57.

SET VAR vresult = (BRND(1234.5678342,8,.01))

***

The datatype may then be easily redefined to suit your purpose, so that display formatting is reliable child's play:

SET VAR vresult DOUBLE

SET VAR vresult TEXT

SET VAR vresult CURRENCY

Best, Bruce

------ Original Message ------
From "'Karen Tellef' via RBASE-L" <rbase-l@googlegroups.com>
To "rbase-l@googlegroups.com" <rbase-l@googlegroups.com>
Date 11/8/2023 12:43:13 PM
Subject Re: [RBASE-L] - Where do I set my Vars?


Welcome to the not-so-wonderful world of the "REAL" datatype. Long ago in DOS days that was the only datatype (other than currency) that allowed decimals. Unfortunately it isn't real accurate IMO (pun intended). Most of us switched all those Real numbers to the DOUBLE datatype. With Double, a 104.31 is always stored and displayed exactly as 104.31. With Real, internally that number may be stored as something like 104.309187983. So depending on your display formatting, you could get different representations to the screen.

Looks like the 000.## type of formatting might be truncating. In my example, it would display as 104.30 or 104.309 even tho the number is actually 104.31. Someone else suggested using the ROUND function if you know how many decimal places you want displayed.

Karen


On Wednesday, November 8, 2023 at 01:47:25 PM CST, lin...@gmail.com <linc...@gmail.com> wrote:


Hello Razzak,

Thank you - that is what I was looking for. I knew there was a simple solution.

I am getting a strange output though:  the real number stored is 104.31
    000.## prints as 104.30
    000.### prints as 104.309

This is an unusual situation where the number stored could possibly be 4 numbers to the left of the decimal and 3 to the right (we have never had more than 2 to the right)

thanks for the help!

Lin

On Tuesday, November 7, 2023 at 7:57:30 PM UTC-8 Razzak Memon wrote:
Lin,

Here's how ...

Please take a look at the attached illustration.
Open the report in Report Designer
Right-click on the Variable Object and select Display Format
Under the Display Format option change the Display Format to 0.000
Click on the [OK] button to save the Display Format
Click on the [Preview] Tab to preview while still in Report Designer
Save the report and close the Report Designer
That's all there is to it!

I hope it helps!

Very Best Regards,

Razzak


On 11/07/2023 8:53 PM EST Lin MacDonald <li...@fastmail.fm> wrote:


This will sound silly, but I am working on a system that I wrote several years ago, but can't remember most of what I wrote!

I have a report that prints a Var (type: Real) It is now printing it with 7 places after the decimal point. I need it to print a max of 3 places. Where do I set the number of places? I honestly can't rmemeber!

Lin


--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+u...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/1c446867-f6d4-49b8-adc4-3252ed914b4b%40app.fastmail.com <https://groups.google.com/d/msgid/rbase-l/1c446867-f6d4-49b8-adc4-3252ed914b4b%40app.fastmail.com?utm_medium=email&utm_source=footer>.

--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/rbase-l/c065ed53-23d4-4581-baa4-11a2e5034242n%40googlegroups.com <https://groups.google.com/d/msgid/rbase-l/c065ed53-23d4-4581-baa4-11a2e5034242n%40googlegroups.com?utm_medium=email&utm_source=footer>
.

--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/1942164164.930636.1699476193291%40mail.yahoo.com <https://groups.google.com/d/msgid/rbase-l/1942164164.930636.1699476193291%40mail.yahoo.com?utm_medium=email&utm_source=footer>.

--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rbase-l+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/em0b30dafb-67aa-4542-9f29-7b76da2b1ed7%40ffc94789.com.

Reply via email to