US20080262801A1 - Tower of numeric types - Google Patents

Tower of numeric types Download PDF

Info

Publication number
US20080262801A1
US20080262801A1 US11/787,586 US78758607A US2008262801A1 US 20080262801 A1 US20080262801 A1 US 20080262801A1 US 78758607 A US78758607 A US 78758607A US 2008262801 A1 US2008262801 A1 US 2008262801A1
Authority
US
United States
Prior art keywords
numeric
tower
data types
computer
statically defined
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
US11/787,586
Other versions
US7890320B2 (en
Inventor
Melitta Andersen
Ryan Byington
Brian Grunkemeyer
James S. Miller
Anthony J. Moore
Ariel Weinstein
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Microsoft Technology Licensing LLC
Original Assignee
Microsoft Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Microsoft Corp filed Critical Microsoft Corp
Priority to US11/787,586 priority Critical patent/US7890320B2/en
Assigned to MICROSOFT CORPORATION reassignment MICROSOFT CORPORATION ASSIGNMENT OF ASSIGNORS INTEREST (SEE DOCUMENT FOR DETAILS). Assignors: ANDERSEN, MELITTA, WEINSTEIN, ARIEL, MOORE, ANTHONY J., BYINGTON, RYAN, GRUNKEMEYER, BRIAN, MILLER, JAMES S.
Publication of US20080262801A1 publication Critical patent/US20080262801A1/en
Application granted granted Critical
Publication of US7890320B2 publication Critical patent/US7890320B2/en
Assigned to MICROSOFT TECHNOLOGY LICENSING, LLC reassignment MICROSOFT TECHNOLOGY LICENSING, LLC ASSIGNMENT OF ASSIGNORS INTEREST (SEE DOCUMENT FOR DETAILS). Assignors: MICROSOFT CORPORATION
Active legal-status Critical Current
Adjusted expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation

Definitions

  • statically typed languages One common problem that occurs with statically typed languages is the difficulty in performing basic mathematical operations between two different strongly-typed numeric types. For example, suppose you have a first variable that is an integer. Further suppose that you have a second variable that is a floating point number. If you try and perform an addition operation between the first variable and the second variable, you could receive a type conversion error.
  • numeric tower that represents a structure supporting statically defined numeric data types.
  • the numeric data types each are operable to implement a different but accurate representation of a particular value.
  • Numeric operations are supported for the numeric tower that can be performed with any of the statically defined numeric data types.
  • the numeric tower is extensible, and allows for additional statically defined numeric data types to be added.
  • the numeric tower is also operable to detect overflow situations. For example, suppose a result of an operation will result in an overflow situation because the operation does not fit within a range supported by the particular numeric type. The system converts the numeric type to a different one of the numeric data types in the numeric tower when the result does not fit within a range supported by the first one.
  • FIG. 1 is a diagrammatic view of a computer system of one implementation.
  • FIG. 2 is a diagrammatic view of a numeric tower application of one implementation operating on the computer system of FIG. 1 .
  • FIG. 3 is a high-level process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in representing values in a numeric tower structure.
  • FIG. 4 is a process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in extending the numeric tower with new types and operations.
  • FIG. 5 is a process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in performing a downward conversion to a result of an operation.
  • FIG. 6 is a process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in handling overflow situations.
  • FIG. 7 is a process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in using multiple numeric towers by different parts of a computer program.
  • FIG. 8 is an exemplary diagram of a numeric tower and the various data type definition that one implementation may be composed of.
  • the system may be described in the general context as an application that creates statically typed numeric data types that are not traditionally represented in computer applications, but the system also serves other purposes in addition to these.
  • one or more of the techniques described herein can be implemented as features within a software development program such as MICROSOFT® VISUAL STUDIO®, from a framework for providing software development such as MICROSOFT® .NET Framework, or from any other type of program or service that manipulates numeric data types.
  • a software development program such as MICROSOFT® VISUAL STUDIO®
  • a framework for providing software development such as MICROSOFT® .NET Framework
  • one or more of the techniques described herein are implemented as features within other applications that deal with statically typed data.
  • Abstract types are computer programs intended to represent information in a way that is independent of details of the particular representation of data.
  • an instance of the abstract type integer could be used to represent the mathematical idea of the number 22, without regard to whether this is represented using 8 bits, 16 bits, a sign bit, or a fixed point notation.
  • An instance of an abstract type provides a set of operations that can be performed on the instance.
  • all instances of the abstract type integer would include operations such as negate, add, subtract, inverse and so forth.
  • Concrete types are computer programs intended to implement a specific set of operations using a particular data representation. For example, byte represents an integer using 8 bits and all the operations on it compute either a byte or return an error if the result cannot be represented that way.
  • the system provides a numeric tower that provides a set of abstract (“mathematical”) types which are implemented in terms of a user-specified set of concrete types.
  • a typical numeric tower might include the abstract types number, complex-number, real-number, rational-number, and integer. These form a tower in the sense that all integers are rational-numbers, all rational-numbers are real-numbers, etc.
  • One abstract type (say number) is said to be above another type (say integer) in the tower when any instance of the second type is an instance of the first type (all integers are numbers, so number is above integer in the tower).
  • a typical operation on an abstract type that is part of the tower would be “number multiply(number)” meaning that the operation has the name “multiply” and it takes as input a number and returns a number.
  • This operation is available on all of the types in the tower—you can start with an integer or a real-number or a rational-number and multiply it by any number and get back another number.
  • an exemplary computer system to use for implementing one or more parts of the system includes a computing device, such as computing device 100 .
  • computing device 100 In its most basic configuration, computing device 100 typically includes at least one processing unit 102 and memory 104 .
  • memory 104 may be volatile (such as RAM), non-volatile (such as ROM, flash memory, etc.) or some combination of the two.
  • This most basic configuration is illustrated in FIG. 1 by dashed line 106 .
  • device 100 may also have additional features/functionality.
  • device 100 may also include additional storage (removable and/or non-removable) including, but not limited to, magnetic or optical disks or tape.
  • additional storage is illustrated in FIG. 1 by removable storage 108 and non-removable storage 110 .
  • Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data.
  • Memory 104 , removable storage 108 and non-removable storage 110 are all examples of computer storage media.
  • Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by device 100 . Any such computer storage media may be part of device 100 .
  • Computing device 100 includes one or more communication connections 114 that allow computing device 100 to communicate with other computers/applications 115 .
  • Device 100 may also have input device(s) 112 such as keyboard, mouse, pen, voice input device, touch input device, etc.
  • Output device(s) 111 such as a display, speakers, printer, etc. may also be included. These devices are well known in the art and need not be discussed at length here.
  • computing device 100 includes numeric tower application 200 . Numeric tower application 200 will be described in further detail in FIG. 2 .
  • Numeric tower application 200 is one of the application programs that reside on computing device 100 .
  • Numeric tower application 200 can alternatively or additionally be embodied as computer-executable instructions on one or more computers and/or in different variations than shown on FIG. 1 .
  • one or more parts of numeric tower application 200 can be part of system memory 104 , on other computers and/or applications 115 , or other such variations as would occur to one in the computer software art.
  • Numeric tower application 200 includes program logic 204 , which is responsible for carrying out some or all of the techniques described herein.
  • Program logic 204 includes logic for providing a numeric tower representing a structure supporting multiple statically defined numeric data types, the data types each being operable to implement a different but accurate representation of a particular value (e.g. to implement a whole number, decimal expansion, A+BI where I is imaginary, etc.), and optionally allowing multiple numeric towers to be represented simultaneously 206 ; logic for providing a plurality of numeric operations for the numeric tower that can be performed with any of the statically defined numeric data types 208 ; logic for enabling the numeric tower to allow statically defined numeric data types to be added and/or removed (i.e.
  • program logic 204 is operable to be called programmatically from another program, such as using a single call to a procedure in program logic 204 .
  • a programming language or other numeric tower consumer may interpret the expression “2* ⁇ ” as constructing an integer and a real number, then use the numeric tower to choose an appropriate representation for the operands and convert them, perform the multiplication, choose a representation for the result, and determine whether an overflow occurred.
  • FIG. 3 is a high level process flow diagram for numeric tower application 200 illustrating the stages involved in representing values in a numeric tower structure.
  • the process of FIG. 3 is at least partially implemented in the operating logic of computing device 100 .
  • the process begins at start point 240 with providing an extensible numeric tower representing a structure supporting statically defined data types that each are operable to implement a different but accurate representation of a particular value (stage 242 ).
  • the numeric tower has several features related to representing a particular value most appropriately.
  • the numeric tower puts the abstract types that form the tower into an order from lowest (like integer) to highest (like number). It associates concrete types (called “representations”) with each abstract type, and orders these concrete types from “most restrictive” to “least restrictive.” For example, the concrete type “8-bit integer” is typically considered more restrictive than “16-bit integer” and both are considered to be implementations of the abstract type “integer.”
  • the numeric tower provides an operation to take an instance of an abstract type and convert it to a less restrictive representation type, either of the same abstract type or of a higher abstract type. This is called an upward conversion and is expected to succeed in the usual case.
  • conversion as used herein is meant to include a value-preserving transformation.
  • the numeric tower provides an operation which takes an instance an abstract type and converts it to a more restrictive representation type. This is called a downward conversion and it is to be expected that this operation may fail. For example, attempting to downward convert a rational number of 3/2 will typically fail because there it cannot be represented in any integer concrete type.
  • transformations that do not precisely preserve the value called “coercions”, may alternatively or additionally be provided.
  • the numeric tower is able to allow statically defined numeric data types to be added and/or removed (i.e. adjusted) (stage 244 ).
  • An extensible set of numeric operations are provided for the numeric tower that can be performed with the statically defined numeric data types (stage 246 ). These extensible numeric operations can be added and/or removed.
  • the numeric tower provides a framework for implementing these generic operations.
  • a generic operation like “number multiply(number)” starts with a concrete representation (the “self” operand) and another concrete representation and uses the upward conversion operation on each until it finds a pair of representations that actually implement multiplication of the two concrete types. It then takes the result and downward converts the result until it finds the lowest representation that can hold the result.
  • FIG. 4 illustrates one implementation of the stages involved in extending the numeric tower with new types and operations.
  • the process of FIG. 4 is at least partially implemented in the operating logic of computing device 100 .
  • the process begins at start point 270 with providing an extensible numeric tower for use in objected oriented programming environments, the numeric tower having a structure that supports multiple statically defined numeric data types that can each represent a particular value (stage 272 ).
  • a set of extensible operations are provided that work on arbitrary data types (e.g. the data types in the numeric tower) (stage 274 ).
  • the set of extensible operations can be representation agnostic and/or representation specific.
  • abstract mathematical types and related operations can be represented in the object oriented programming environment using the static types in the numeric tower (stage 276 ).
  • the process ends at end point 278 .
  • FIG. 5 illustrates one implementation of the stages involved in performing a downward conversion to a result of an operation.
  • the process of FIG. 5 is at least partially implemented in the operating logic of computing device 100 .
  • the process begins at start point 280 with receiving a request to perform an operation on at least one first particular one of a plurality of statically defined numeric types in a numeric tower (stage 282 ).
  • the system determines that a result of the operation should be represented using a lower numeric type located in a lower category in the numeric tower than an original numeric type being used to represent the result (stage 284 ).
  • the system performs downward conversions to find the lowest numeric type that can hold the result—e.g. by stopping with the numeric type associated with the last conversion that does not fail (stage 286 ).
  • the result is returned in the lowest numeric type that can hold the result (stage 288 ).
  • the process ends at end point 289 .
  • FIG. 6 illustrates one implementation of the stages involved in handling overflow situations.
  • the process of FIG. 6 is at least partially implemented in the operating logic of computing device 100 .
  • the process begins at start point 290 with receiving a request to perform an operation on at least one particular one of the statically defined numeric types (stage 292 ).
  • the system determines whether a result of the operation will result in an overflow situation when the operation does not fit within a range supported by the particular one of the numeric types (stage 294 ).
  • the particular one of the numeric data types is converted to a second one of the numeric data types where the result does not fit within a range supported by the first numeric data type (stage 296 ).
  • the process ends at end point 298 .
  • FIG. 7 illustrates one implementation of the stages involved in using multiple numeric towers with different parts of a computer program.
  • the process of FIG. 7 is at least partially implemented in the operating logic of computing device 100 .
  • the process begins at start point 300 with generating a first numeric tower for a first portion of a computer program (stage 302 ).
  • the system generates a second and distinctly different numeric tower for a second portion of a computer program (stage 304 ).
  • the numeric towers are different because different programming languages have a different set of common types exposed in them.
  • numeric towers By providing multiple numeric towers, it is possible to perform one set of operations with the first numeric tower having certain rules and types, and then use a different set of rules and types for performing operations on the second numeric tower (stage 306 ).
  • a default tower can be selected (stage 308 ).
  • the multiple numeric towers are implemented by using different instances of a numeric tower. In another implementation, the multiple numeric towers are implemented by using static variables with process space isolation to construct multiple non-overlapping towers. The process ends at end point 310 .
  • FIG. 8 illustrates an exemplary numeric tower structure 320 and the data types it contains.
  • the structures of FIG. 8 are at least partially implemented in the operating logic of computing device 100 .
  • number tower application 320 At the bottom of number tower application 320 is a signed and/or un-signed integer number type 328 , which is defined as values that can be expressed as a positive, zero, or negative whole number.
  • the next level of the numeric tower is a rational number type 326 , which is defined as a value that is capable of being expressed as a quotient of two integers where the denominator is not zero.
  • the next level of the numeric tower is a real number type 324 , which is defined as a value that is capable of being expressed in decimal notation (using a finite or infinite number of digits).
  • the final level of the numeric tower is a complex number type 322 which is defined as a real number added to a real number multiplied by an imaginary number (e.g. the square root of ⁇ 1). While four numeric data types are shown in the example numeric tower 320 , in other implementations, some, all, and/or additional numeric data types can be included in the numeric tower. The system allows the next data type in the list to be chosen to represent a particular value if that type would be better for handling a particular situation.
  • the system also allows for the result of an operation to be converted downward in the tower if that result is capable of being represented by one of the lower levels.
  • One non-limiting example of when such “downward conversion” may be used is if the result of an operation performed on two rational numbers results in a value that can be represented by an integer.

Abstract

Various technologies and techniques are disclosed for providing a numeric tower that represents a structure supporting statically defined numeric data types. The numeric data types each are operable to implement a different but accurate representation of a particular value. Numeric operations are supported for the numeric tower that can be performed with any of the statically defined numeric data types. The numeric tower is extensible, and allows for additional statically defined numeric data types to be added, as well as operations. The numeric tower is also operable to detect overflow situations. For example, suppose a result of an operation will result in an overflow situation because the operation does not fit within a range supported by the particular numeric type. The system converts the numeric type to a different one of the numeric data types when the result does not fit within a range supported by the first one.

Description

    BACKGROUND
  • In the abstract mathematical world, numbers are separated into different categories based on the operations you can perform on them. In the world of computers, categories differ based on representation. For example, in mathematics, there is no difference between 6/3 and 2, but on a computer, the first is represented by two integers and the second by one integer. At the most basic level, in mathematics, there are integers. These are numbers that we use most often (e.g. 1, 2, 3, 4, etc.), are the easiest to comprehend and represent, and are used by most computing devices. The next category of numbers in mathematics includes rational numbers. Rational numbers are defined to be anything that can be expressed as one integer divided by another integer. The next category includes real numbers. A real number is a value that is capable of being expressed in decimal notation (e.g. using a finite or infinite number of digits). The final category of numbers in the mathematical world includes complex numbers which are typically expressed as a+bi, where a and b are real numbers, and i is an imaginary unit representing √−1.
  • These abstract mathematical types are difficult to represent and interact with using a computer. As noted above, most computers use the integer category of numbers. Computers further sub-divide this category into more specific types, such as 8-bit integers, 16-bit integers, and several others. Numbers with a decimal point are commonly represented using floating point types, which approximate a real number to a particular precision. Furthermore, software programming languages allow the software developer to declare a variable that has a numeric type that matches these sub-divisions. In computer programming, if a programming language requires that all variables be of a specific type, then that language is called statically typed (or strongly typed).
  • One common problem that occurs with statically typed languages is the difficulty in performing basic mathematical operations between two different strongly-typed numeric types. For example, suppose you have a first variable that is an integer. Further suppose that you have a second variable that is a floating point number. If you try and perform an addition operation between the first variable and the second variable, you could receive a type conversion error.
  • SUMMARY
  • Various technologies and techniques are disclosed for providing a numeric tower that represents a structure supporting statically defined numeric data types. The numeric data types each are operable to implement a different but accurate representation of a particular value. Numeric operations are supported for the numeric tower that can be performed with any of the statically defined numeric data types. The numeric tower is extensible, and allows for additional statically defined numeric data types to be added. The numeric tower is also operable to detect overflow situations. For example, suppose a result of an operation will result in an overflow situation because the operation does not fit within a range supported by the particular numeric type. The system converts the numeric type to a different one of the numeric data types in the numeric tower when the result does not fit within a range supported by the first one.
  • This Summary was provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
  • BRIEF DESCRIPTION OF THE DRAWINGS
  • FIG. 1 is a diagrammatic view of a computer system of one implementation.
  • FIG. 2 is a diagrammatic view of a numeric tower application of one implementation operating on the computer system of FIG. 1.
  • FIG. 3 is a high-level process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in representing values in a numeric tower structure.
  • FIG. 4 is a process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in extending the numeric tower with new types and operations.
  • FIG. 5 is a process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in performing a downward conversion to a result of an operation.
  • FIG. 6 is a process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in handling overflow situations.
  • FIG. 7 is a process flow diagram for one implementation of the system of FIG. 1 illustrating the stages involved in using multiple numeric towers by different parts of a computer program.
  • FIG. 8 is an exemplary diagram of a numeric tower and the various data type definition that one implementation may be composed of.
  • DETAILED DESCRIPTION
  • For the purposes of promoting an understanding of the principles of the invention, reference will now be made to the embodiments illustrated in the drawings and specific language will be used to describe the same. It will nevertheless be understood that no limitation of the scope is thereby intended. Any alterations and further modifications in the described embodiments, and any further applications of the principles as described herein are contemplated as would normally occur to one skilled in the art.
  • The system may be described in the general context as an application that creates statically typed numeric data types that are not traditionally represented in computer applications, but the system also serves other purposes in addition to these. In one implementation, one or more of the techniques described herein can be implemented as features within a software development program such as MICROSOFT® VISUAL STUDIO®, from a framework for providing software development such as MICROSOFT® .NET Framework, or from any other type of program or service that manipulates numeric data types. In another implementation, one or more of the techniques described herein are implemented as features within other applications that deal with statically typed data.
  • Abstract types are computer programs intended to represent information in a way that is independent of details of the particular representation of data. For example, an instance of the abstract type integer could be used to represent the mathematical idea of the number 22, without regard to whether this is represented using 8 bits, 16 bits, a sign bit, or a fixed point notation. An instance of an abstract type provides a set of operations that can be performed on the instance. For example, all instances of the abstract type integer would include operations such as negate, add, subtract, inverse and so forth. Concrete types are computer programs intended to implement a specific set of operations using a particular data representation. For example, byte represents an integer using 8 bits and all the operations on it compute either a byte or return an error if the result cannot be represented that way.
  • In one implementation, the system provides a numeric tower that provides a set of abstract (“mathematical”) types which are implemented in terms of a user-specified set of concrete types. A typical numeric tower, for example, might include the abstract types number, complex-number, real-number, rational-number, and integer. These form a tower in the sense that all integers are rational-numbers, all rational-numbers are real-numbers, etc. One abstract type (say number) is said to be above another type (say integer) in the tower when any instance of the second type is an instance of the first type (all integers are numbers, so number is above integer in the tower).
  • A typical operation on an abstract type that is part of the tower would be “number multiply(number)” meaning that the operation has the name “multiply” and it takes as input a number and returns a number. This operation is available on all of the types in the tower—you can start with an integer or a real-number or a rational-number and multiply it by any number and get back another number.
  • As shown in FIG. 1, an exemplary computer system to use for implementing one or more parts of the system includes a computing device, such as computing device 100. In its most basic configuration, computing device 100 typically includes at least one processing unit 102 and memory 104. Depending on the exact configuration and type of computing device, memory 104 may be volatile (such as RAM), non-volatile (such as ROM, flash memory, etc.) or some combination of the two. This most basic configuration is illustrated in FIG. 1 by dashed line 106.
  • Additionally, device 100 may also have additional features/functionality. For example, device 100 may also include additional storage (removable and/or non-removable) including, but not limited to, magnetic or optical disks or tape. Such additional storage is illustrated in FIG. 1 by removable storage 108 and non-removable storage 110. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Memory 104, removable storage 108 and non-removable storage 110 are all examples of computer storage media. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by device 100. Any such computer storage media may be part of device 100.
  • Computing device 100 includes one or more communication connections 114 that allow computing device 100 to communicate with other computers/applications 115. Device 100 may also have input device(s) 112 such as keyboard, mouse, pen, voice input device, touch input device, etc. Output device(s) 111 such as a display, speakers, printer, etc. may also be included. These devices are well known in the art and need not be discussed at length here. In one implementation, computing device 100 includes numeric tower application 200. Numeric tower application 200 will be described in further detail in FIG. 2.
  • Turning now to FIG. 2 with continued reference to FIG. 1, a numeric tower application 200 operating on computing device 100 is illustrated. Numeric tower application 200 is one of the application programs that reside on computing device 100. However, it will be understood that Numeric tower application 200 can alternatively or additionally be embodied as computer-executable instructions on one or more computers and/or in different variations than shown on FIG. 1. Alternatively or additionally, one or more parts of numeric tower application 200 can be part of system memory 104, on other computers and/or applications 115, or other such variations as would occur to one in the computer software art.
  • Numeric tower application 200 includes program logic 204, which is responsible for carrying out some or all of the techniques described herein. Program logic 204 includes logic for providing a numeric tower representing a structure supporting multiple statically defined numeric data types, the data types each being operable to implement a different but accurate representation of a particular value (e.g. to implement a whole number, decimal expansion, A+BI where I is imaginary, etc.), and optionally allowing multiple numeric towers to be represented simultaneously 206; logic for providing a plurality of numeric operations for the numeric tower that can be performed with any of the statically defined numeric data types 208; logic for enabling the numeric tower to allow statically defined numeric data types to be added and/or removed (i.e. adjusted) to the structure having the data types 210; logic for enabling the numeric tower to allow numeric operations to be added and/or removed (i.e. adjusted) for use by the statically defined numeric data types 212; logic for enabling the numeric tower to select a particular representation of the particular value based upon an operation to be performed 214; logic for providing at least one conversion operation that can be used to convert the particular value from a first one of the statically defined numeric data types to a second one of the statically defined numeric data types 216; logic for determining whether a result of the operation will result in an overflow situation when the operation does not fit within a range supported by the particular one of the numeric types and for optionally converting to one of the other numeric data types when the operation does not fit within the supported range 218; and other logic for operating the application 220. In one implementation, program logic 204 is operable to be called programmatically from another program, such as using a single call to a procedure in program logic 204. For example, a programming language (or other numeric tower consumer) may interpret the expression “2*π” as constructing an integer and a real number, then use the numeric tower to choose an appropriate representation for the operands and convert them, perform the multiplication, choose a representation for the result, and determine whether an overflow occurred.
  • Turning now to FIGS. 3-7 with continued reference to FIGS. 1-2, the stages for implementing one or more implementations of numeric tower application 200 are described in further detail. FIG. 3 is a high level process flow diagram for numeric tower application 200 illustrating the stages involved in representing values in a numeric tower structure. In one form, the process of FIG. 3 is at least partially implemented in the operating logic of computing device 100. The process begins at start point 240 with providing an extensible numeric tower representing a structure supporting statically defined data types that each are operable to implement a different but accurate representation of a particular value (stage 242). In one implementation, the numeric tower has several features related to representing a particular value most appropriately. For example, the numeric tower puts the abstract types that form the tower into an order from lowest (like integer) to highest (like number). It associates concrete types (called “representations”) with each abstract type, and orders these concrete types from “most restrictive” to “least restrictive.” For example, the concrete type “8-bit integer” is typically considered more restrictive than “16-bit integer” and both are considered to be implementations of the abstract type “integer.” Alternatively or additionally, the numeric tower provides an operation to take an instance of an abstract type and convert it to a less restrictive representation type, either of the same abstract type or of a higher abstract type. This is called an upward conversion and is expected to succeed in the usual case. The term conversion as used herein is meant to include a value-preserving transformation. For example, it might take an integer (an abstract type) which is represented as an 8-bit integer (concrete type) and return the same number but represented at a 16-bit integer (concrete type). It might take a 64-bit integer (concrete type) and return the same number as a rational number made from two infinite precision integers (concrete type). Alternatively or additionally, the numeric tower provides an operation which takes an instance an abstract type and converts it to a more restrictive representation type. This is called a downward conversion and it is to be expected that this operation may fail. For example, attempting to downward convert a rational number of 3/2 will typically fail because there it cannot be represented in any integer concrete type. In another implementation, transformations that do not precisely preserve the value, called “coercions”, may alternatively or additionally be provided.
  • The numeric tower is able to allow statically defined numeric data types to be added and/or removed (i.e. adjusted) (stage 244). An extensible set of numeric operations are provided for the numeric tower that can be performed with the statically defined numeric data types (stage 246). These extensible numeric operations can be added and/or removed. The numeric tower provides a framework for implementing these generic operations. A generic operation like “number multiply(number)” starts with a concrete representation (the “self” operand) and another concrete representation and uses the upward conversion operation on each until it finds a pair of representations that actually implement multiplication of the two concrete types. It then takes the result and downward converts the result until it finds the lowest representation that can hold the result. Thus, if you start with an 8-bit integer representing 2 and a rational representing 3/2 it would first upward convert the 2 to a rational of 2/1, then multiply the two rationals 2/1 and 3/2 to get a rational of 6/2, then downward convert this to get the 8-bit integer 3. A result of an operation is stored such that the particular value is represented with at least one of the data types in the numeric tower (stage 248). The process ends at end point 250.
  • FIG. 4 illustrates one implementation of the stages involved in extending the numeric tower with new types and operations. In one form, the process of FIG. 4 is at least partially implemented in the operating logic of computing device 100. The process begins at start point 270 with providing an extensible numeric tower for use in objected oriented programming environments, the numeric tower having a structure that supports multiple statically defined numeric data types that can each represent a particular value (stage 272). A set of extensible operations are provided that work on arbitrary data types (e.g. the data types in the numeric tower) (stage 274). The set of extensible operations can be representation agnostic and/or representation specific. By providing the numeric tower with the extensible operations, abstract mathematical types and related operations can be represented in the object oriented programming environment using the static types in the numeric tower (stage 276). The process ends at end point 278.
  • FIG. 5 illustrates one implementation of the stages involved in performing a downward conversion to a result of an operation. In one form, the process of FIG. 5 is at least partially implemented in the operating logic of computing device 100. The process begins at start point 280 with receiving a request to perform an operation on at least one first particular one of a plurality of statically defined numeric types in a numeric tower (stage 282). The system determines that a result of the operation should be represented using a lower numeric type located in a lower category in the numeric tower than an original numeric type being used to represent the result (stage 284). The system performs downward conversions to find the lowest numeric type that can hold the result—e.g. by stopping with the numeric type associated with the last conversion that does not fail (stage 286). The result is returned in the lowest numeric type that can hold the result (stage 288). The process ends at end point 289.
  • FIG. 6 illustrates one implementation of the stages involved in handling overflow situations. In one form, the process of FIG. 6 is at least partially implemented in the operating logic of computing device 100. The process begins at start point 290 with receiving a request to perform an operation on at least one particular one of the statically defined numeric types (stage 292). The system determines whether a result of the operation will result in an overflow situation when the operation does not fit within a range supported by the particular one of the numeric types (stage 294). The particular one of the numeric data types is converted to a second one of the numeric data types where the result does not fit within a range supported by the first numeric data type (stage 296). The process ends at end point 298.
  • FIG. 7 illustrates one implementation of the stages involved in using multiple numeric towers with different parts of a computer program. In one form, the process of FIG. 7 is at least partially implemented in the operating logic of computing device 100. The process begins at start point 300 with generating a first numeric tower for a first portion of a computer program (stage 302). The system generates a second and distinctly different numeric tower for a second portion of a computer program (stage 304). In one implementation, the numeric towers are different because different programming languages have a different set of common types exposed in them. By providing multiple numeric towers, it is possible to perform one set of operations with the first numeric tower having certain rules and types, and then use a different set of rules and types for performing operations on the second numeric tower (stage 306). When multiple numeric towers are involved (e.g. such as a program that wants to evaluate expressions using multiple language's rules, perhaps because the application's components were written within multiple languages), a default tower can be selected (stage 308).
  • In one implementation, the multiple numeric towers are implemented by using different instances of a numeric tower. In another implementation, the multiple numeric towers are implemented by using static variables with process space isolation to construct multiple non-overlapping towers. The process ends at end point 310.
  • FIG. 8 illustrates an exemplary numeric tower structure 320 and the data types it contains. In one form, the structures of FIG. 8 are at least partially implemented in the operating logic of computing device 100. At the bottom of number tower application 320 is a signed and/or un-signed integer number type 328, which is defined as values that can be expressed as a positive, zero, or negative whole number. The next level of the numeric tower is a rational number type 326, which is defined as a value that is capable of being expressed as a quotient of two integers where the denominator is not zero. The next level of the numeric tower is a real number type 324, which is defined as a value that is capable of being expressed in decimal notation (using a finite or infinite number of digits). The final level of the numeric tower is a complex number type 322 which is defined as a real number added to a real number multiplied by an imaginary number (e.g. the square root of −1). While four numeric data types are shown in the example numeric tower 320, in other implementations, some, all, and/or additional numeric data types can be included in the numeric tower. The system allows the next data type in the list to be chosen to represent a particular value if that type would be better for handling a particular situation. In one implementation, the system also allows for the result of an operation to be converted downward in the tower if that result is capable of being represented by one of the lower levels. One non-limiting example of when such “downward conversion” may be used is if the result of an operation performed on two rational numbers results in a value that can be represented by an integer.
  • In one implementation, by enabling the correct data type to be used in the numeric tower for a particular situation, overflow situations can be avoided and/or solved.
  • Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. All equivalents, changes, and modifications that come within the spirit of the implementations as described herein and/or by the following claims are desired to be protected.
  • For example, a person of ordinary skill in the computer software art will recognize that the client and/or server arrangements, user interface screen content, and/or data layouts as described in the examples discussed herein could be organized differently on one or more computers to include fewer or additional options or features than as portrayed in the examples.

Claims (20)

1. A computer-readable medium having computer executable instructions for causing a computer to perform steps comprising:
provide a numeric tower, the numeric tower representing a structure supporting a plurality of statically defined numeric data types, the numeric data types each being capable of implementing a different but accurate representation of a particular value;
provide a plurality of numeric operations for the numeric tower that can be performed with any of the statically defined numeric data types; and
provide at least one conversion operation for the numeric tower that can be used to convert the particular value from one of the statically defined numeric data types to another one of the statically defined numeric data types.
2. The computer-readable medium of claim 1, wherein the numeric tower is operable to represent the particular value using at least one of the data types.
3. The computer-readable medium of claim 1, wherein the numeric tower selects a particular representation of the particular value based on an operation to be performed.
4. The computer-readable medium of claim 1, wherein the numeric tower is operable to report a failure when an exception occurs.
5. The computer-readable medium of claim 1, wherein the numeric tower is operable to allow statically defined data types to be adjusted within the structure having the plurality of statically defined data types.
6. The computer-readable medium of claim 1, wherein the numeric tower is operable to allow numeric operations to be adjusted for use by the plurality of statically defined data types.
7. The computer-readable medium of claim 1, wherein one of the statically defined data types is operable to represent the particular value as a whole number.
8. The computer-readable medium of claim 1, wherein one of the statically defined data types is operable to represent the particular value as a quotient of two integers where the denominator is not zero.
9. The computer-readable medium of claim 1, wherein one of the statically defined data types is operable to represent the particular value as a finite or infinite decimal expansion.
10. The computer-readable medium of claim 1, wherein one of the statically defined data types is operable to represent the particular value that is capable of being expressed in the form of a real number added to a real number multiplied by an imaginary number.
11. The computer-readable medium of claim 1, further having computer executable instructions for causing a computer to perform the step comprising:
allow more than one of the numeric tower to be represented simultaneously.
12. A method for providing an extensible numeric tower of numeric data types comprising the steps of:
providing an extensible numeric tower, the extensible numeric tower representing a structure supporting a plurality of statically defined numeric data types, the plurality of numeric data types each being operable to implement a different but accurate representation of a particular value, the extensible numeric tower being operable to allow additional statically defined numeric data types to be added to the plurality of numeric data types.
13. The method of claim 12, further comprising:
providing an extensible set of numeric operations for the numeric tower that can be performed with the statically defined numeric data types.
14. The method of claim 12, wherein the numeric tower is operable to provide a definition for converting from a particular statically defined type to at least one other particular statically defined type within the numeric tower.
15. The method of claim 12, wherein the numeric tower is operable to allow for reporting a failure when an exception occurs.
16. The method of claim 12, wherein the numeric tower is operable to allow for a result of an operation to be stored such that the particular value is represented with at least one of the numeric data types.
17. A method for providing for performing a downward conversion of numeric types based upon an operation performed on at least one statically defined numeric type consisting of:
receiving a request to perform an operation on at least one first particular one of a plurality of statically defined numeric types in a numeric tower;
determining that a result of the operation should be represented using a lower numeric type located in a lower category in the numeric tower; and
performing a downward conversion on the result to find a lower numeric type that can hold the result; and
returning the result in the lower numeric type that can hold the result.
18. The method of claim 17, wherein the downward conversion is performed one or more times to find the lowest numeric type that can hold the result.
19. The method of claim 18, wherein the lowest numeric type that can hold the result is a last particular numeric type that does not fail the downward conversion.
20. A computer-readable medium having computer-executable instructions for causing a computer to perform the steps recited in claim 17.
US11/787,586 2007-04-17 2007-04-17 Tower of numeric types Active 2028-10-13 US7890320B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US11/787,586 US7890320B2 (en) 2007-04-17 2007-04-17 Tower of numeric types

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
US11/787,586 US7890320B2 (en) 2007-04-17 2007-04-17 Tower of numeric types

Publications (2)

Publication Number Publication Date
US20080262801A1 true US20080262801A1 (en) 2008-10-23
US7890320B2 US7890320B2 (en) 2011-02-15

Family

ID=39873122

Family Applications (1)

Application Number Title Priority Date Filing Date
US11/787,586 Active 2028-10-13 US7890320B2 (en) 2007-04-17 2007-04-17 Tower of numeric types

Country Status (1)

Country Link
US (1) US7890320B2 (en)

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5572642A (en) * 1991-05-16 1996-11-05 Baba Laboratory Inc. Data input display system for preparing and editing structural data
US5933641A (en) * 1997-03-24 1999-08-03 Tritech Microelectronics International, Ltd. Numeric intensive real-time software development system
US5999938A (en) * 1997-01-31 1999-12-07 Microsoft Corporation System and method for creating a new data structure in memory populated with data from an existing data structure
US6052526A (en) * 1997-04-17 2000-04-18 Vertel Corporation Data structure and method for dynamic type resolution using object-oriented programming language representation of information object sets
US6400287B1 (en) * 2000-07-10 2002-06-04 International Business Machines Corporation Data structure for creating, scoping, and converting to unicode data from single byte character sets, double byte character sets, or mixed character sets comprising both single byte and double byte character sets
US20030005418A1 (en) * 2001-03-19 2003-01-02 C. Sridhar Method for allocation, initialization and access of aggregate data types for architectures with differing memory granularity
US20030172249A1 (en) * 1999-10-25 2003-09-11 Kumar Ganapathy Methods of performing DSP operations with complex data type operands
US6728722B1 (en) * 2000-08-28 2004-04-27 Sun Microsystems, Inc. General data structure for describing logical data spaces
US20040123276A1 (en) * 2002-12-19 2004-06-24 Paul Knueven Assembly directives for the support of multi-language programming
US7062500B1 (en) * 1997-02-25 2006-06-13 Intertrust Technologies Corp. Techniques for defining, using and manipulating rights management data structures
US7111284B2 (en) * 2001-01-18 2006-09-19 Hitachi, Ltd. System and method for mapping structured document to structured data of program language and program for executing its method
US7143101B2 (en) * 2003-04-18 2006-11-28 Andy Oliver Method and apparatus for self-describing externally defined data structures
US7143076B2 (en) * 2000-12-12 2006-11-28 Sap Aktiengesellschaft Method and apparatus for transforming data

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5572642A (en) * 1991-05-16 1996-11-05 Baba Laboratory Inc. Data input display system for preparing and editing structural data
US5999938A (en) * 1997-01-31 1999-12-07 Microsoft Corporation System and method for creating a new data structure in memory populated with data from an existing data structure
US7062500B1 (en) * 1997-02-25 2006-06-13 Intertrust Technologies Corp. Techniques for defining, using and manipulating rights management data structures
US5933641A (en) * 1997-03-24 1999-08-03 Tritech Microelectronics International, Ltd. Numeric intensive real-time software development system
US6052526A (en) * 1997-04-17 2000-04-18 Vertel Corporation Data structure and method for dynamic type resolution using object-oriented programming language representation of information object sets
US20030172249A1 (en) * 1999-10-25 2003-09-11 Kumar Ganapathy Methods of performing DSP operations with complex data type operands
US6400287B1 (en) * 2000-07-10 2002-06-04 International Business Machines Corporation Data structure for creating, scoping, and converting to unicode data from single byte character sets, double byte character sets, or mixed character sets comprising both single byte and double byte character sets
US6728722B1 (en) * 2000-08-28 2004-04-27 Sun Microsystems, Inc. General data structure for describing logical data spaces
US7143076B2 (en) * 2000-12-12 2006-11-28 Sap Aktiengesellschaft Method and apparatus for transforming data
US7111284B2 (en) * 2001-01-18 2006-09-19 Hitachi, Ltd. System and method for mapping structured document to structured data of program language and program for executing its method
US20030005418A1 (en) * 2001-03-19 2003-01-02 C. Sridhar Method for allocation, initialization and access of aggregate data types for architectures with differing memory granularity
US20040123276A1 (en) * 2002-12-19 2004-06-24 Paul Knueven Assembly directives for the support of multi-language programming
US7143101B2 (en) * 2003-04-18 2006-11-28 Andy Oliver Method and apparatus for self-describing externally defined data structures

Also Published As

Publication number Publication date
US7890320B2 (en) 2011-02-15

Similar Documents

Publication Publication Date Title
JP6282116B2 (en) Associating captured image data with a spreadsheet
JP4889204B2 (en) Medium and system for processing input parameters of commands to shell
KR101805946B1 (en) Generating text manipulation programs using input-output examples
US7634720B2 (en) System and method for providing context to an input method
US9075833B2 (en) Generating XML schema from JSON data
US8645350B2 (en) Dictionary compilations
Miller et al. Problem solving with algorithms and data structures using python Second Edition
US20120011152A1 (en) Generating Programs Based on Input-Output Examples Using Converter Modules
JP2006053894A (en) Support of spread sheet function specified by user
JPH09508726A (en) Numerical formatting framework
JP2006228210A (en) Using existing content to generate active content wizard executable file for execution of task
JP5244826B2 (en) Separation, management and communication using user interface elements
US20190243643A1 (en) Mapping api parameters
JP2011159302A (en) Xml payload specification for modeling edi schema
Nagar Introduction to Python for Engineers and Scientists: Open Source Solutions for Numerical Computation
US10672295B2 (en) Accessible metadata in data structures
US20080082535A1 (en) Method and system for automatically generating a communication interface
US20060143207A1 (en) Cyrillic to Latin script transliteration system and method
US7890320B2 (en) Tower of numeric types
US8490051B2 (en) Generic interface for numeric types
JP4845523B2 (en) Character processing apparatus, method, program, and recording medium
US8296731B2 (en) Dynamic method selection based on declarative requirements of interaction scope
US8108828B2 (en) System for generating optimized computer data field conversion routines
JP2019133534A (en) Merging method, merging device, and merging program
CN111475156B (en) Page code generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
AS Assignment

Owner name: MICROSOFT CORPORATION, WASHINGTON

Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:ANDERSEN, MELITTA;BYINGTON, RYAN;GRUNKEMEYER, BRIAN;AND OTHERS;REEL/FRAME:019329/0839;SIGNING DATES FROM 20070403 TO 20070411

Owner name: MICROSOFT CORPORATION, WASHINGTON

Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:ANDERSEN, MELITTA;BYINGTON, RYAN;GRUNKEMEYER, BRIAN;AND OTHERS;SIGNING DATES FROM 20070403 TO 20070411;REEL/FRAME:019329/0839

STCF Information on status: patent grant

Free format text: PATENTED CASE

FPAY Fee payment

Year of fee payment: 4

AS Assignment

Owner name: MICROSOFT TECHNOLOGY LICENSING, LLC, WASHINGTON

Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:MICROSOFT CORPORATION;REEL/FRAME:034542/0001

Effective date: 20141014

MAFP Maintenance fee payment

Free format text: PAYMENT OF MAINTENANCE FEE, 8TH YEAR, LARGE ENTITY (ORIGINAL EVENT CODE: M1552)

Year of fee payment: 8

MAFP Maintenance fee payment

Free format text: PAYMENT OF MAINTENANCE FEE, 12TH YEAR, LARGE ENTITY (ORIGINAL EVENT CODE: M1553); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY

Year of fee payment: 12