numeric representation too big for Integer. [message #1300376] |
Thu, 17 April 2014 10:26  |
Eclipse User |
|
|
|
Hi,
I need to process a numeric string which is too big to fit in an int.
A value which fails:
4294967295
This is actually the exact max size of an unsigned int, but java int is
32bit signed, so this won't fit. So I guess I need a unsigned int here.
I tried changing the return type to EBigDecimal and EBigInteger but I
still get errors/markers in the editor.
terminal INT returns ecore::EInt:
'-'? ('0'..'9')+;
Do I need to implement an IValueConverter or is there a way to handle
this in the grammar directly.?
Thank You,
Christophe
|
|
|
|
|
Re: numeric representation too big for Integer. [message #1300737 is a reply to message #1300401] |
Thu, 17 April 2014 15:46  |
Eclipse User |
|
|
|
On 17-04-14 16:49, Christian Dietrich wrote:
> Hi,
>
> yes you have to
>
> BIG_INT returns ecore::EBigInteger:
> INT
> ;
Thanks!
>
> public class MyDslConverters extends DefaultTerminalConverters {
>
> @Inject
> private BigIntegerValueConverter bigIntegerValueConverter;
>
> @ValueConverter(rule = "BIG_INT")
> public IValueConverter<BigInteger> BIG_INT() {
> return bigIntegerValueConverter;
> }
>
> private static class BigIntegerValueConverter extends
> AbstractLexerBasedConverter<BigInteger> {
>
> @Override
> public BigInteger toValue(String string, INode node)
> throws ValueConverterException {
> try {
> return new BigInteger(string);
> } catch (NumberFormatException e) {
> throw new ValueConverterException("Kein BigInteger",
> node, e);
> }
> }
>
> }
>
> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.04493 seconds