Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365393 - [Xbase] NumberExtensions and IntegerExtensions
Summary: [Xbase] NumberExtensions and IntegerExtensions
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: M4   Edit
Assignee: Jan Koehnlein CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-02 02:40 EST by Sven Efftinge CLA
Modified: 2017-09-19 17:47 EDT (History)
2 users (show)

See Also:
sven.efftinge: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Efftinge CLA 2011-12-02 02:40:05 EST
Define arithmetic operators for all kind of numbers including primitives and their wrappers as well as BigInteger and BigDecimal.

The primitive versions should be overloaded for the most commonly used cases.

IntegerExtensions needs methods for other Java operators like shifting.
Comment 1 Jan Koehnlein CLA 2011-12-02 09:47:12 EST
Integer and Double pushed to MASTER.
Now heading for BigInteger and BigDecimal
Comment 2 Jan Koehnlein CLA 2011-12-02 10:52:39 EST
Bound the following operators

  ! && || == !=                           for (boolean, boolean)
  - + ** * / % || && == != < <= > >= !    for (int, int) and (Integer, Number)
  - + ** * / % || && == != < <= > >= ! .. for (Integer, Number)
  - + ** * / == != < <= > >=              for (double, double)
  - + ** * /                              for (Double, Number)
  - + ** * /                              for (BigDecimal, BigDecimal)
  - + ** * / % || && !                    for (BigInteger, BigInteger)

Into the bargain, I've added the shift operators from Java as methods.

For the Object types, there is no need to override the default Comparable binding, as long as we don't plan to support comparing e.g. Double to BigInteger transparently.

I've skipped char, byte, short and float in this first shot. I've also skipped mixed primitve operations like int+double.
Comment 3 Jan Koehnlein CLA 2011-12-02 10:59:57 EST
Pushed to MASTER
Comment 4 Jan Koehnlein CLA 2011-12-02 12:18:40 EST
Found a problem with autoboxing. Generated Java code doesn't comple, because
  operator_plus(new Integer(a), 1) 
is ambiguos.
Comment 5 Jan Koehnlein CLA 2011-12-02 13:49:28 EST
The XbaseCompiler now explicitly boxes and unboxes primitives and their wrappers. 

Also converted bit operations on integer types into methods which are more suggestive to non-mathematicians ;-)
Comment 6 Karsten Thoms CLA 2017-09-19 17:36:18 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 7 Karsten Thoms CLA 2017-09-19 17:47:14 EDT
Closing all bugs that were set to RESOLVED before Neon.0