Focal Point    Focal Point Forums    iWay Software Product Forum on Focal Point    [CLOSED] Yanking the last digit from decimals

 Go Search Notify Tools
 [CLOSED] Yanking the last digit from decimals
Member
 posted November 06, 2017 05:27 PM
How would I yank the last digit from a 3 decimal places to two without rounding the 2 decimal place?

This message has been edited. Last edited by: FP Mod Chuck,

WebFOCUS 8105
Windows, Excel

 Posts: 15 | Registered: November 03, 2017 IP
Expert
 posted November 06, 2017 05:34 PM Hide Post
Stick the number into a packed decimal field.

DEFINE/COMPUTE NEWFIELD/P20.2 = MY20D3FIELD ;

Waz...

 Prod: WebFOCUS 7.6.10/8.1.04 Upgrade: WebFOCUS 8.2.07 OS: Linux Outputs: HTML, PDF, Excel, PPT In Focus since 1984 Pity the lost knowledge of an old programmer!

 Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006 IP
Member
 posted November 07, 2017 04:19 AM Hide Post
You can use define or compute for changing the format else simple put format with / for example

TABLE FILE CAR
SUM
SALES/D20.2
BY MODEL
END

FORMAT D20.2 will restrict yr decimal filed value upto 2 decimal place.

webfcous 8202m
windows 7

 Posts: 6 | Registered: July 25, 2017 IP
Member
 posted November 07, 2017 08:17 AM Hide Post
Hello,

It is still rounding the next digit.

Here is what I need:
1.999 will be 1.99
I hope this help some.

WebFOCUS 8105
Windows, Excel

 Posts: 15 | Registered: November 03, 2017 IP
Platinum Member
 posted November 07, 2017 09:33 AM Hide Post
You can be trying the one method of use INT. This not be nice but work!
```TABLE FILE CAR
SUM COMPUTE VALUE/D12.3 = IF LAST VALUE EQ 0 THEN 1.99 ELSE LAST VALUE + 0.001;
-* This is be line important for you
COMPUTE BASE/P7.2 = INT(VALUE * 100) / 100;
BY CAR
END```

Kofi

Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012

 Posts: 106 | Registered: April 06, 2009 IP
Platinum Member
 posted November 07, 2017 09:36 AM Hide Post
Forgot, no use double precision as is retains all decimals - no good for you and this. Need packed decimal like Waz say as no retain decimals after using INT.

Kofi

Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012

 Posts: 106 | Registered: April 06, 2009 IP
Expert
 posted November 07, 2017 03:16 PM Hide Post
quote:
It is still rounding the next digit.

Ho PO,

What code did you use ?

The P format should work for you

Waz...

 Prod: WebFOCUS 7.6.10/8.1.04 Upgrade: WebFOCUS 8.2.07 OS: Linux Outputs: HTML, PDF, Excel, PPT In Focus since 1984 Pity the lost knowledge of an old programmer!

 Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006 IP
Master
 posted December 08, 2017 04:48 PM Hide Post
Multiple it by 1000 then convert it to an alpha with the edit function, then replace the last character with a 0, then convert is back to a decimal and then device by 1000.

Scott

 Posts: 865 | Registered: May 24, 2004 IP