﻿Functions.SetDigit Method (DWord)

# Functions.SetDigit Method (DWord)

Return and optionally change the setting that determines the number of digits that will be shown to the left of the decimal point when a number is displayed.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.16
Syntax
``` FUNCTION SetDigit(
nNewSetting AS DWORD
) AS DWORD```

#### Parameters

nNewSetting
Type: DWord
The number of digits to show.
The initial default is 10.
A negative value indicates that only the significant whole digits to the left of the decimal point (the mantissa) are returned.
Any right padding is also suppressed.

#### Return Value

Type: DWord
If nNewSetting is not specified, SetDigit() returns the current setting.
If nNewSetting is specified, the previous setting is returned.
Remarks
SetDigit() and SetDigitFixed() can be used together to control the way digits are displayed: When SetDigitFixed() is TRUE, display of numeric output is fixed according to the SetDigit() value. When SetDigitFixed() is FALSE, numeric output displays according to the default rules for numeric display. To provide finer control of numeric display, you can use the PICTURE clause of @...SAY, @...GET, and the Transform() function. A -1 for nNewSetting implies that only significant whole digits to the left of the decimal are to be displayed (any leading zeros will be suppressed.)
Tip
SetDigit() affects only the display format of numbers, not the actual numeric precision of calculations.
Examples
This example shows typical uses of SetDigit():
X#
``` 1FUNCTION Start()
2    LOCAL nSaveDigit AS SHORTINT
3    ? 1234                // 1234
4                        // Initial setting is 10 digits
5                        // Number is displayed right justified
6                        // Save current setting, then reset to 5 digits
7    nSaveDigit := SetDigit(5)
8    ? 1234                //  234
9    ? 1234.567                //  1234.567
10    ? 123456                // *****
11    SetDigit(nSaveDigit)        // Restore the old setting
12    ? 1234                //  1234
13    RETURN TRUE```