question

Upvotes
Accepted
33 9 13 31

EMA Java: example to covert the BigDecimal to OMMReal

Do we have an example that can be referred to convert a Java BigDecimal to OMMReal (mantissa and magnitude) so can be populated in the expression like below:

fieldList.add(EmaFactory.createFieldEntry().real(22, <mantissa>, <magnitude>));

Searched the forum and found one in the question description:

https://community.developers.refinitiv.com/questions/51833/how-to-set-real-fids-to-blank-using-java-ema.html

ema-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
Accepted
79.1k 250 52 74

@Frederic

I can't find an example for it. However, you can try this code.

BigDecimal test = new BigDecimal("125.5831200");
fieldList.add( EmaFactory.createFieldEntry().real(25, test.unscaledValue().longValue(),  OmmReal.MagnitudeType.EXPONENT_0 - test.scale()));

BigDecimal::unscaledValue() returns a BigInteget whose value is the unscaled value of this BigDecimal. I think it is mantissa of OMMReal.

BigDecimal::unscaledValue() returns the scale of this BigDecimal. We need to convert this value to the OMMReal hint (magnitude).

This is a simple snippet code. It isn't fully tested and doesn't cover all use cases.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.