Classic ASP Framework
org.classicasp.primitive.NumberEx

A data type representing a double-precision floating-point number. You can manipulate primitive numeric values by using the methods and properties associated with the NumberEx class.

To create a NumberEx object, you can use the constructor or the global function, or assign a literal value.

Example

	
  Response.Write NumberEx(12345.6789).toPrecision(2).toPaddedString(10).toJSON()
  

Output

"0012345.68"

Summary

Returns a globally unique identifier (GUID), ex {946EA7E2-6A58-4341-98A4-D78BC1A9A7D4}.
Returns a alpha-numeric globally unique identifier (GUID), ex 946EA7E26A58434198A4D78BC1A9A7D4.
Returns a boolean value indicating if the value is even.
Returns a boolean value indicating if the value is odd.
Returns a random number.
Converts a number to a character using (chr) (1=a, 26=z, 27=27).
Returns a Bencoded string representation of the object.
Convert the number into a degrees (Radians * 180 / MathUtilEx.
Returns a json encoded string representation of the object.
Converts the number into a string padded with 0s so that the string's length is at least equal to length.
Formats the number to a specified number of decimal places.
Convert the number into a radians (Degrees * MathUtilEx.
Returns a string representation of the object.
Converts the number to a temperature.
Returns an XML encoded string representation of the object.
Writes a json encoded string representation of the object.
Writes an XML encoded string representation of the object.

guid

Public Function guid()

Returns a globally unique identifier (GUID), ex

{946EA7E2-6A58-4341-98A4-D78BC1A9A7D4}.

Returns

StringEx

guid2

Public Function guid2()

Returns a alpha-numeric globally unique identifier (GUID), ex

946EA7E26A58434198A4D78BC1A9A7D4.

Returns

StringEx

isEven

Public Function isEven()
Returns a boolean value indicating if the value is even.

Returns

BooleanEx

Example

		
	  Response.Write NumberEx(10).isEven().toJSON()
	  

Output

True

isOdd

Public Function isOdd()
Returns a boolean value indicating if the value is odd.

Returns

BooleanEx

Example

		
	  Response.Write NumberEx(10).isOdd().toJSON()
	  

Output

False

random

Public Function random()
Returns a random number.

Returns

NumberEx

Example

		
	  Response.Write NumberEx("").random().toJSON()
	  

Output

448994226

toAlphaChar

Public Function toAlphaChar()
Converts a number to a character using (chr) (1=a, 26=z, 27=27).

Returns

StringEx

toBencode

Public Function toBencode()
Returns a Bencoded string representation of the object.

Returns

String

Example

		
	  Response.Write NumberEx(100).toBencode()
	  

Output

i100e

toDegrees

Public Function toDegrees()
Convert the number into a degrees (Radians * 180 / MathUtilEx.PI).

Returns

NumberEx

toJSON

Public Function toJSON()
Returns a json encoded string representation of the object.

Returns

String

Example

		
	  Response.Write NumberEx(100).toJSON()
	  

Output

100

toPaddedString

Public Function toPaddedString(ByRef lInputLength)
Converts the number into a string padded with 0s so that the string's length is at least equal to length.

Returns

StringEx

Example

		
	  Response.Write NumberEx(100).toPaddedString("10").toJSON()
	  

Output

"0000000100"

toPrecision

Public Function toPrecision(ByRef lInputPrecision)
Formats the number to a specified number of decimal places.

Returns

NumberEx

Example

		
	  Response.Write NumberEx(100.328358).toPrecision(2).toJSON()
	  

Output

100.33

toRadians

Public Function toRadians()
Convert the number into a radians (Degrees * MathUtilEx.PI / 180).

Returns

NumberEx

toString

Public Function toString()
Returns a string representation of the object.

Returns

StringEx

toTemperature

Public Function toTemperature(
ByRef sInputFrom,
ByRef sInputTo)
Converts the number to a temperature.

Input

  • f - Fahrenheit
  • c - Celsius
  • k - Kelvin

Returns

NumberEx

Example

		
	  Response.Write NumberEx(32).toTemperature("f", "c").toJSON()
	  

Output

0

toXML

Public Function toXML()
Returns an XML encoded string representation of the object.

Returns

String

Example

		
	  Response.Write NumberEx(100).toXML()
	  

Output

<data type="Number">100</data>

writeJSON

Public Sub writeJSON()
Writes a json encoded string representation of the object.

Returns

N/A

Example

		
	  Call NumberEx(100).writeJSON()
	  

Output

100

writeXML

Public Sub writeXML()
Writes an XML encoded string representation of the object.

Returns

N/A

Example

		
	  Call NumberEx(100).writeXML()
	  

Output

<data type="Number">100</data>

'***ClassicASP.org
'Copyright 2010 ClassicASP.org

'This file is part of ClassicASP Framework.

'ClassicASP-Framework is free software: you can redistribute it and/or modify
'it under the terms of the GNU General Public License as published by
'the Free Software Foundation, version 3 of the License.

'ClassicASP-Framework is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.

'You should have received a copy of the GNU General Public License
'along with ClassicASP-Framework. If not, see .

'For additional information please visit .

Created with TwinText