picofuse-objc

Instance Methods | Class Methods | List of all members
NXNumber Class Reference

An integer, floating point or boolean value, as an object. More...

#import <Foundation/Foundation.h>

Inheritance diagram for NXNumber:
Inheritance graph
[legend]
Collaboration diagram for NXNumber:
Collaboration graph
[legend]

Instance Methods

(BOOL) - boolValue
 Returns YES if the value isn't zero. More...
 
(int16_t) - int16Value
 Returns the value as a 16-bit signed integer. More...
 
(uint16_t) - unsignedInt16Value
 Returns the value as a 16-bit unsigned integer. More...
 
(int32_t) - int32Value
 Returns the value as a 32-bit signed integer. More...
 
(uint32_t) - unsignedInt32Value
 Returns the value as a 32-bit unsigned integer. More...
 
(int64_t) - int64Value
 Returns the value as a 64-bit signed integer. More...
 
(uint64_t) - unsignedInt64Value
 Returns the value as a 64-bit unsigned integer. More...
 
(float) - float32Value
 Returns the value as a 32-bit floating point value, which is infinite if it's out of range.
 
(double) - float64Value
 Returns the value as a 64-bit floating point value.
 
(BOOL) - isEqual:
 Returns YES if the other object is a number with exactly the same value, whatever they were made from. More...
 
(NXComparisonResult) - compare:
 Compares the number with another, by value, exactly, whatever their types: 1 and 1.0 are the same, and 2^53 + 1 is after 2^53 as a float. More...
 
(uintptr_t) - hash
 Returns a hash of the value, which is the same for equal numbers, such as 1, 1.0 and true.
 
(NXString *) - description
 Returns the value as a string, which is "true" or "false" for a boolean. More...
 
- Instance Methods inherited from NXObject
(void) - dealloc
 Frees the instance. More...
 
(NXZone *) - zone
 Returns the zone in which the instance was allocated. More...
 
(id) - retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id) - autorelease
 Releases the receiver later, when the current autorelease pool of the thread is drained. More...
 
(id) - copy
 Returns a copy which can't be changed by anything else, which the caller owns and has to release. More...
 
- Instance Methods inherited from Object
(id) - init
 Initialize the instance, after allocation. More...
 
(Class) - class
 Returns the class of the instance. More...
 
(Class) - superclass
 Returns the superclass of the instance. More...
 
(BOOL) - isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL) - conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL) - respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(NXNumber *) + numberWithBool:
 Returns a number for a boolean value, which is trueValue or falseValue.
 
(NXNumber *) + numberWithInt16:
 Returns a number for a 16-bit signed integer. More...
 
(NXNumber *) + numberWithUnsignedInt16:
 Returns a number for a 16-bit unsigned integer. More...
 
(NXNumber *) + numberWithInt32:
 Returns a number for a 32-bit signed integer. More...
 
(NXNumber *) + numberWithUnsignedInt32:
 Returns a number for a 32-bit unsigned integer. More...
 
(NXNumber *) + numberWithInt64:
 Returns a number for a 64-bit signed integer. More...
 
(NXNumber *) + numberWithUnsignedInt64:
 Returns a number for a 64-bit unsigned integer. More...
 
(NXNumber *) + numberWithFloat32:
 Returns a number for a 32-bit floating point value. More...
 
(NXNumber *) + numberWithFloat64:
 Returns a number for a 64-bit floating point value. More...
 
(NXNumber *) + numberWithString:
 Returns a number from a string, or nil if it isn't one. More...
 
(NXNumber *) + randomInt32
 Returns a number for a random 32-bit signed integer.
 
(NXNumber *) + randomUnsignedInt32
 Returns a number for a random 32-bit unsigned integer.
 
(NXNumber *) + randomInt64
 Returns a number for a random 64-bit signed integer.
 
(NXNumber *) + randomUnsignedInt64
 Returns a number for a random 64-bit unsigned integer.
 
(NXNumber *) + trueValue
 Returns the number for true, which is equal to one.
 
(NXNumber *) + falseValue
 Returns the number for false, which is equal to zero.
 
(NXNumber *) + zeroValue
 Returns the number for zero, as a signed integer.
 
- Class Methods inherited from NXObject
(id) + alloc
 Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More...
 
(id) + allocWithZone:
 Allocates a new instance in a specific zone. More...
 
(id) + new
 Allocates and initializes a new instance, as [[cls alloc] init] does. More...
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(Class) + class
 Returns the class object. More...
 
(Class) + superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL) + conformsTo:
 Checks if the class conforms to a protocol. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

An integer, floating point or boolean value, as an object.

Numbers can't be changed. They're made in the current autorelease pool, other than zeros, true and false: there's only one of each of those, which is never deallocated, and doesn't need a pool. There are three zeros, which are equal: a signed integer, an unsigned integer and a floating point number. Every number which is made as zero is the one of its kind, other than floating point negative zero, which is made in the pool like any other.

A number can be returned as any type, whatever it was made from. As an integer, the fraction of a floating point value is discarded, and it panics if the value is out of range, or isn't a number. As a floating point value, it may be rounded.

A number can't change, so any number of threads can use it at once. See Threads and mutable objects.

Definition at line 52 of file NXNumber.h.

Method Documentation

◆ boolValue()

- (BOOL) boolValue

Returns YES if the value isn't zero.

That includes what isn't a number.

◆ compare:()

- (NXComparisonResult) compare: (NXNumber *)  other

Compares the number with another, by value, exactly, whatever their types: 1 and 1.0 are the same, and 2^53 + 1 is after 2^53 as a float.

Not a number is after every number, and the same as itself. If other is nil, it's compared with zero.

◆ description()

- (NXString *) description

Returns the value as a string, which is "true" or "false" for a boolean.

A floating point value is rounded, to six significant digits if it's 32-bit, or otherwise nine.

Implements NXObject.

◆ int16Value()

- (int16_t) int16Value

Returns the value as a 16-bit signed integer.

Panics if it's out of range.

◆ int32Value()

- (int32_t) int32Value

Returns the value as a 32-bit signed integer.

Panics if it's out of range.

◆ int64Value()

- (int64_t) int64Value

Returns the value as a 64-bit signed integer.

Panics if it's out of range.

◆ isEqual:()

- (BOOL) isEqual: (id)  anObject

Returns YES if the other object is a number with exactly the same value, whatever they were made from.

A floating point value which isn't a number is only equal to the same object.

Implements Object.

◆ numberWithFloat32:()

+ (NXNumber *) numberWithFloat32: (float)  value

Returns a number for a 32-bit floating point value.

Returns
The number, which is the floating point zero if the value is zero but not negative zero, or nil if the allocation failed.

◆ numberWithFloat64:()

+ (NXNumber *) numberWithFloat64: (double)  value

Returns a number for a 64-bit floating point value.

Returns
The number, which is the floating point zero if the value is zero but not negative zero, or nil if the allocation failed.

◆ numberWithInt16:()

+ (NXNumber *) numberWithInt16: (int16_t)  value

Returns a number for a 16-bit signed integer.

Returns
The number, which is zeroValue if the value is zero, or nil if the allocation failed.

◆ numberWithInt32:()

+ (NXNumber *) numberWithInt32: (int32_t)  value

Returns a number for a 32-bit signed integer.

Returns
The number, which is zeroValue if the value is zero, or nil if the allocation failed.

◆ numberWithInt64:()

+ (NXNumber *) numberWithInt64: (int64_t)  value

Returns a number for a 64-bit signed integer.

Returns
The number, which is zeroValue if the value is zero, or nil if the allocation failed.

◆ numberWithString:()

+ (NXNumber *) numberWithString: (NXString *)  string

Returns a number from a string, or nil if it isn't one.

Parameters
stringThe whole of it is one of:
  • "true" or "false", which are booleans
  • an integer, with or without a sign, such as "42" or "-7", or in hex ("0x1F"), binary ("0b101") or octal ("0o17", or "017" with a leading zero)
  • a float, such as "3.14", ".5", "1e10" or "-1.5e-3", or "NaN", "Inf" or "-Inf"

Nothing else is allowed, such as spaces or a zero byte. An integer is signed if it fits in an int64_t, else unsigned if it fits in a uint64_t, else a float, which may not be exact. One in hex, binary or octal which doesn't fit is nil.

◆ numberWithUnsignedInt16:()

+ (NXNumber *) numberWithUnsignedInt16: (uint16_t)  value

Returns a number for a 16-bit unsigned integer.

Returns
The number, which is the unsigned zero if the value is zero, or nil if the allocation failed.

◆ numberWithUnsignedInt32:()

+ (NXNumber *) numberWithUnsignedInt32: (uint32_t)  value

Returns a number for a 32-bit unsigned integer.

Returns
The number, which is the unsigned zero if the value is zero, or nil if the allocation failed.

◆ numberWithUnsignedInt64:()

+ (NXNumber *) numberWithUnsignedInt64: (uint64_t)  value

Returns a number for a 64-bit unsigned integer.

Returns
The number, which is the unsigned zero if the value is zero, or nil if the allocation failed.

◆ unsignedInt16Value()

- (uint16_t) unsignedInt16Value

Returns the value as a 16-bit unsigned integer.

Panics if it's out of range.

◆ unsignedInt32Value()

- (uint32_t) unsignedInt32Value

Returns the value as a 32-bit unsigned integer.

Panics if it's out of range.

◆ unsignedInt64Value()

- (uint64_t) unsignedInt64Value

Returns the value as a 64-bit unsigned integer.

Panics if it's out of range.


The documentation for this class was generated from the following file: