Skip to content

Commit

Permalink
b1.2.3.20210718
Browse files Browse the repository at this point in the history
- Due to a typo and a missing return value for an overloaded operator, comparison operators would sometimes report incorrect results. (Multiverse7)
- Implemented the := operator, introduced in v514. This allows the library to be used more transparently, because now a method does not need to be (explicitly) used to assign data into a LongInt object.
- Updated the documentation to address the := operator.
  • Loading branch information
popisfizzy committed Jul 19, 2021
1 parent 95d992a commit d7bc2a4
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 17 deletions.
40 changes: 25 additions & 15 deletions +Documentation.dm
@@ -1,7 +1,7 @@
/**
** pif_LongInt
** Version: b1.2.2.20171227
** Release Date: December 27, 2017
** Version: b1.2.3.20210718
** Release Date: July 18, 2021
**
***************************************************************************************************
***************************************************************************************************
Expand Down Expand Up @@ -106,24 +106,15 @@ integers are available.
Thanks to the introduction of operator overloading in BYOND v512, you can now use pif_LongInt
objects in a largely-"transparent" way. That is, you can use the built-in operators without much
concern for the fact that these are objects. There are three exceptions to this:
concern for the fact that these are objects. There are two exceptions to this:
(1) As these are objects, they must be created and initialized.
var/pif_LongInt
Unsigned32/U = new(50) // U is created with a value of 50.
Signed32/S = new(-5) // S is created with a value of -5.
(2) Assigning a new value to an existing pif_LongInt object must be done using the Set() method,
rather than the assignment operation.
U.Set(500) // 500 is now stored in U.
S.Set(28) // 28 is now stored in S.
Using the assignment operator will result in that value being stored in the variable, rather
than in the object.
(3) To display the value of the object, one must use the Print() method.
(2) To display the value of the object, one must use the Print() method.
world << (U*S).Print() // This will output "14000".
Expand Down Expand Up @@ -285,11 +276,30 @@ integers are available.
----------------------+----------+---------------------------------------------------------------
Less Than Or Equal To | <= | Returns true if hte left hand side is less than or is equal to
| | the right hand side, and false otherwise.
----------------------+----------+---------------------------------------------------------------/
----------------------+----------+---------------------------------------------------------------
ASSIGNMENT OPERATORS
Name | Operator | Behavior
----------------------+----------+---------------------------------------------------------------
Assignment | := | Assigns the value on the right hand side of the operator to
| | the LongInt object. This will accept any value that is in one
| | of the General Arithmetic Argument Formats found in
| | 'pif_Arithmetic protocol.dm'
----------------------+----------+---------------------------------------------------------------
4. Release Notes
----------------------------------------------------
Version b1.2.3.20210718
- Due to a typo and a missing return value for an overloaded operator, comparison operators would
sometimes report incorrect results. (Multiverse7)
- Implemented the := operator, introduced in v514. This allows the library to be used more
transparently, because now a method does not need to be (explicitly) used to assign data into
a LongInt object.
- Updated the documentation to address the := operator.
Version b1.2.2.20171227
- Fixed a bug that would result in empty arguments (except in constructors) would result in a
Expand Down Expand Up @@ -374,7 +384,7 @@ integers are available.
----------------------------------------------------
- Write up complete documentation for the library.
- Implement classes for both signed and unsigned 48-bit and 64-bit integers..
- Implement classes for both signed and unsigned 48-bit and 64-bit integers.
- Set up a preprocessor flag that toggles allowing negative remainders or having only positive
remainders. Currently, negative remainders are allowed to appear.
- Set up a flag that disables overflow/underflow checking entirely, avoiding the processor cycles
Expand Down
2 changes: 1 addition & 1 deletion +License.dm
Expand Up @@ -2,7 +2,7 @@
MIT License
Copyright (c) 2016-2017 Timothy "popisfizzy" Reilly
Copyright (c) 2016-2021 Timothy "popisfizzy" Reilly
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
Expand Down
21 changes: 21 additions & 0 deletions pif_LongInt Subclasses/Signed32.dm
Expand Up @@ -5140,5 +5140,26 @@ though the downside that remainders may be negative.
proc/operator<(...)
return Compare(arglist(args)) == -1
proc/operator<=(...)
return Compare(arglist(args)) != 1

#endif

#if (DM_VERSION < 514)
#warn BYOND v514 or newer required to use the := operator
#else

/*
* This implements the := operator, which is more recent than the other operators. It allows datums
* to be used more "transparently", without having to overtly call a method to change the value
* stored in the object.
*/

proc/operator:=(...)
var/list/Processed = _ProcessArguments(args)

block_1 = Processed[1]
block_2 = Processed[2]

return src

#endif
22 changes: 21 additions & 1 deletion pif_LongInt Subclasses/Unsigned32.dm
Expand Up @@ -2937,7 +2937,7 @@ LongInt/Unsigned32
return (. > 0) ? 1 : -1

. = block_1 - B1
return (. == 0) ? 0 : ( (. > 1) ? 1 : -1)
return (. == 0) ? 0 : ( (. > 0) ? 1 : -1)

EqualTo(...)
return Compare(arglist(args)) == 0
Expand Down Expand Up @@ -4284,4 +4284,24 @@ LongInt/Unsigned32
proc/operator<=(...)
return Compare(arglist(args)) != 1

#endif

#if (DM_VERSION < 514)
#warn BYOND v514 or newer required to use the := operator
#else

/*
* This implements the := operator, which is more recent than the other operators. It allows datums
* to be used more "transparently", without having to overtly call a method to change the value
* stored in the object.
*/

proc/operator:=(...)
var/list/Processed = _ProcessArguments(args)

block_1 = Processed[1]
block_2 = Processed[2]

return src

#endif

0 comments on commit d7bc2a4

Please sign in to comment.