Skip to content
Advertisement

Tag: c++

C compatible printf output for Java

I’d want to convert float/double to string, in Java and C, such that the outputs are both consistent and user friendly. By “user friendly”, I mean the string should be human readable and sound: a maximum number of significant digits, and some automatic switching to scientific notation when appropiate (the double could span all the valid range). By “consistent” I

C# and Java DES Encryption value are not identical

I am trying to encrypt the same data using C# and Java. If the data is more than 7 bytes then Java and C#’s encrypted value are not identical. Input 1: a java output: FrOzOp/2Io8= C# output: FrOzOp/2Io8= Input 2: abc j : H9A/ahl8K7I= c#: H9A/ahl8K7I= Input 3: aaaaaaaa (Problem) j : Gxl7e0aWPd7j6l7uIEuMxA== c#: Gxl7e0aWPd7sf1xR6hK4VQ== Here is the implementation of

How much to grow buffer in a StringBuilder-like C module?

In C, I’m working on a “class” that manages a byte buffer, allowing arbitrary data to be appended to the end. I’m now looking into automatic resizing as the underlying array fills up using calls to realloc. This should make sense to anyone who’s ever used Java or C# StringBuilder. I understand how to go about the resizing. But does

Heap allocation and suitable hardware

For a C# .net 3.5 application which unavoidably creates a lot of data on the heap, in terms of hardware what would I be looking for in terms of memory? Would it just be the largest socket bus width? Or the “bandwidth” of the memory sticks? Or the actual frequency they run at? We have concluded the bottleneck of our

Difference between namespace in C# and package in Java

What is the difference (in terms of use) between namespaces in C# and packages in Java? Answer From: http://www.javacamp.org/javavscsharp/namespace.html Java Packages are used to organize files or public types to avoid type conflicts. Package constructs can be mapped to a file system. may be replaced: There is no alias for packages. You have to use import statement or fully-qualified name

Failed to locate method JNI_GetCreatedJavaVMs in the libjvm.dylib (Mac OS)

I am trying to embed java virtual machine in my program but I libjvm.dylib lacks JNI_GetCreatedJavaVMs. The program works fine both on Windows and on Linux platforms. However, when running on Mac OS I’m getting: exception. I use libjvm.dylib located in /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Libraries directory. I think the issue is in using the wrong libjvm however, I was unable to find it

C++ equivalent to Java this

In Java you can refer to the current object by doing: this.x = x. How do you do this in C++? Assume that each of these code examples are part of a class called Shape. Java: C++: Answer Same word: this Only difference is it is a pointer, so you need to use the -> operator:

volatile with release/acquire semantics

Since Java 5, the volatile keyword has release/acquire semantics to make side-effects visible to other threads (including assignments to non-volatile variables!). Take these two variables, for example: Note that i is a regular, non-volatile variable. Imagine thread 1 executing the following statements: At some later point in time, thread 2 executes the following statements: According to the Java memory model,

codility absolute distinct count from an array

so i took the codility interview test yesterday and was informed today that i failed, unfortunately i wasnt given any other information by either codility nor the employer as to where i screwed up so i would appreciate some help in knowing where i went wrong. i know codility pays alot of emphasis on how fast the program runs and

Advertisement