I working on an asn file structuring.
My existing code is having data type as:
Fieldname::= INTEGER
As per my requirement, I changed it to:
Fieldname::= INTEGER --<HUGE>--
While parsing this value through java, I am using:
int intValue = Fieldname.intValue()
After changing datatype (huge integer) I am getting error:
Error:(750,121) java: cannot find symbol
Cannot resolve method 'intvalue'
This is issue with parser only. How to parse a string to huge int.
You don't say what tooling you are using.
EDIT: from your comment, I understand you are using OSS Nokalva. This is a commercial product and you should seek support from there.
However, this seems quite normal
The --<HUGE>-- is a hint (pragma) for your code generator to use something bigger than an int in your java code.
(Note that, as far as asn.1 is concerned, it is just a comment).
Hence, the accessor will be different: longValue() or bitIntegerValue() or whatever your doc says.
Have a look at the generated code, you'll find it easily
I have fixed this issue.
I have used below code to parse the value in my java code.
BigInteger intValue = Fieldname.bigIntegerValue()
Related
I'm currently working on generating a Word document file from a Word Template using data from a JSON variable in java. I'm using the ASPOSE library.
I have a problem with a specific variable. This variable should print a numeric(float) value. However, when the value is 100.0 ,it is sometimes printed as -2147483648 (-2^31) instead of 100.0.
I have to mention that when the value is a double digit float (for example 35.5 and 99.9),the value of the variable is printed correctly. Also when the input value is integer(e.g 100),the correct value is also printed correctly.
I have also tried to use some format strings(<<[variableName]:"0.##">>) inside the expression tag in the Word Template file, but it didn't fix it.
Here is the DOCX template
This is the input value from JSON file
Here is the generated result
#aggelos991
Using the latest available version of Aspose.Words for Java (i.e. 22.2), I was unable to reproduce the issue. Moreover, we had a similar issue in the past, so it seems like you are using an outdated version of Aspose.Words for Java. Could you please upgrade to the latest version and let us know if the issue is still present?
Float type is in the 32bit format, and 100.0 is in the 64bit format(double). 100.0f must be used for proper use.
We have a program that does pattern replacement in a variety of files (including Excel) and are using Aspose. So for example we might have a cell that is PATTERN_TO_REPLACE and then we replace that with "6" or "6.0" or "1,000.00" (in the US) or "1.000,00" (in the UK).
(PATTERN_TO_REPLACE could also be in a formula).
The problem is that we have to use a Java matcher to find (and replace) the string, which means we are calling cell.setValue(String). This led Aspose to change the CellValueType to string, even when it was previously numeric.
Our initial solution was to look and see if we thought the string was a number, then cast it to a BigDecimal and pass it in as such, but that leads to a lot of work (particularly for localization of types of currencies...)
What I'd like to do is call cell.getStyle(), cell.getType(), save them, set the value, then return them, but there is no cell.setType() method. Is there an easy way to do what I want?
When you use cell.setValue(String), surely, it will set string type. I think you may try to use the overloads like, cell.putValue(String, true) instead. This way, if you are inserting numbers (as string), it will be automatically converted to numbers and set it to numeric type.
PS. I am working as Support developer/ Evangelist at Aspose.
div(1, sum(1, exp(sum(div(5, product(100, .1)), -5))))
I'm using this in a Solr query, and want to verify that it is the same as :
Where x is 5.
Is this language Java?
If it is, why am I getting this output here:
http://ideone.com/LWYWtU
If it isn't, what language is this and how do I test it?
Thanks in advance for your help.
EDIT: To add more of the surrounding code, here is the full boost value I'm sending to Solr:
if(exists(query({!frange l=0 u=60 v=product(geodist(),0.621371)})),div(1, sum(1, exp(sum(div(product(5), product(100, .1)), -5)))),0)
The reason I think it might be Java is because in the docs, it says Most Java Math functions are now supported, including: and then lists the math functions I ended up using for code.
Solr is Java, but that's not relevant since this is a set of functions that Solr parses and evaluate itself (and not related to Java, except that the backing functions are implemented in Java).
As far as I can say from what you've mapped the functions correctly, as long as the 5 in product(5) is the same as X. You shouldn't need product there, as the value can be included in div directly as far as I can see.
A way to validate it would be to use debugQuery in Solr and see what the value is evaluated as, and then compare it to your own value. Remember that floating point evaluation can introduce a few uncertanities.
I use spymemcached 2.6rc1 in my Java project where I want to use the Long class as a storable object. Unfortunately, when I store e.g. new Long(0) object, the get(...) and incr(...) give the wholly different results - get gives Long object that contains 48 value and incr gives 1.
Please note that 48 represents the ASCII "0" symbol. When I try to get the value for the same key directly from memcached (e.g. by using telnet) I get the correct result - 0. Strange, the Long is good serialized class. So, probably, there is some problem with default transcoding. Can somebody clarify how to resolve this situation?
There was an issue filed for this a while back (spymemcached bug 41). Here's what Dustin Sallings, the creator of Spymemcached said about the issue:
You can't mix IntegerTranscoder and incr/decr. incr/decr require the numbers to be
encoded as strings as they are language-agnostic server-side operations.
Here's a unit test that demonstrates what you're trying to do:
public void testIncrDecrBug41() throws Exception {
final String key="incrdecrbug41";
// set to zero
client.set(key, 86400, "0");
// retrieve it to see if it worked
assertEquals("0", client.get(key));
// increment it
assertEquals(1, client.incr(key, 1));
// fetch it again to see if it worked
assertEquals("1", client.get(key));
}
Note that the reason you get 49 is because decimal 49 is the string "1".
incr and decr cause a lot of confusion for people because of the server-side
semantics. In newer version of memcached (e.g. changes I don't have applied yet in
my binary branch), incr and decr will fail on non-numeric string values. That is,
your first incr would throw an exception.
In the future please file bugs at the Spymemcached project website. It can be found at http://code.google.com/p/spymemcached. That way we can fix them sooner.
Hello everybody :)
I am currently using preon for a spare time project, and I have encountered the following problem: I am trying to read a fixed length String with the following code:
#Bound int string_size;
#ByteAlign #BoundString(size = "string_size") my_string;
The file specification expects a variable padding, so that the next block's offset is a multiple of 4.
For example, if string_size = 5, then 3 null bytes will be added, and so on. I initially thought that the #ByteAlign annotation did exactly this, however, looking into the source code, I realized that it wasn't the case.
I tried to make this quick fix:
#If ("string_size % 4 == 2") #BoundList(size = "2", type = Byte.class) byte[] padding;
Sadly, Limbo doesn't seem to support the "%" operator. Is there a way around this?
(Also, where/how can I get the latest version?)
Thanks in advance.
Preon currently doesn't have a solution for your issue built-in. As you said, it's expression language doesn't have a modulo operator, and it looks like you could use one. You can however implement your own CodecDecorator, which is probably the thing you want to do. You could implement a CodecDecorator that inserts a Codec reading a couple of extrac bytes after it decoded the value.
The latest version of Preon is at Codehaus:
git://git.codehaus.org/preon.git
You could checkout the head, but there's also a separate branch called PREON-35 that has the bits for doing what is discussed over here.