Skip to content

Latest commit

 

History

History
80 lines (65 loc) · 2.67 KB

File metadata and controls

80 lines (65 loc) · 2.67 KB

Num2Str

Description

Function Num2Str converts a REAL value to a string and returns the value.

Parameter decPlace has a range of -1 to 9; if -1 is specified, the value will be returned in scientific notation.

FUNCTION Num2Str(
				decPlace : INTEGER;
				v        : REAL): STRING;
def vs.Num2Str(decPlace, v):
    return STRING

Parameters

Name Type Description
decPlace INTEGER Number of decimal places.
v REAL Numeric value.

Remarks

_c_, 2015.05.23: You can also use Concat to convert numbers to strings, but it uses exclusively a dot "." as symbol for the decimal marker, because it outputs the number as seen from inside VS, I suppose. See further comments on the page Concat.

The parameter decPlace can be the following values:

Value Meaning Sample
positive round-up the value 10.56 -> 10.6 (1 decimal place)
0 round-up the value 10.56 -> 11
-1 Use scientific notation (9 decimals) 10.56 -> 1.056000000e+001
-2 Use scientific notation (15 decimals) 10.56 -> 1.056000000000000e+001

Examples

VectorScript

oldnumValue := 232.5148;
newStrValue := Num2Str(3, oldnumValue);
{ --> '232.515' if your system is american }
{ --> '232,515' if your system is metric }

Python

theLabel := Concat(GetPlugInString(3004), Chr(13), Chr(13),
					GetPlugInString(3006), Num2Str(2, theta), Chr(13),
					GetPlugInString(3007), Num2StrF(D), Chr(13),
					GetPlugInString(3008), Num2StrF(T), Chr(13),
					GetPlugInString(3009), Num2StrF(L), Chr(13),
					GetPlugInString(3010), Num2StrF(theRadius));

REPEAT
	alpha := alpha + 1 / incr;
	theta := Deg2Rad (alpha);
	m := (Sin (theta / 2) / theta) - (c / (2 * s));
	m := Str2Num (Num2Str (accuracy, m));
	IF m = 0 THEN
		a := alpha2

BEGIN
	IF numPlaces > 9 THEN numPlaces := 9;
	rRound := Str2Num (Num2Str (numPlaces, a));
END;
result = vs.Num2Str(decPlace, v)

See also in tutorials: 10. Iterate the Drawing and Report a Summary, 11. 2D Vector Math Toolkit, 12. Polygon Area and Centroid (Shoelace Formula), 15. Uniform Arc-Length Resampling of a Polyline

Version

Availability: from All Versions

Category