Question: are Math.getExponent and Math.scalb supported on Android?

by Danke Xie » Thu, 12 Aug 2010 05:06:12 GMT

Sponsored Links

As an experiment, I am trying to port a virtual machine written in
Java to Android platform. However, it heavily uses some special
floating point functions, like getting the exponent, or multiplying a
floating point by a power of 2. These are done with new Java Math
functions scalb and getExponent. It appears that they can be done by
manipulating the binary representation of the floating points.
However, because these functions don't seem to be available on Android
yet (are they?), all I could think of is implementing them with other
functions, like

public static float scalb(float f, int scaleFactor) {
  return f * Math.pow(2, scaleFactor);

public static int getExponent(float f) {
  return (int) (Math.log(f)/Math.log(2));

The question is... if the library doesn't have stock scalb and
getExponent functions, but the code is compiled with a new Java SDK
supporting the new math functions, could the Java compiler still
figure out a way to optimize these functions and operate on the binary
numeric level?



Other Threads

1. Android Target Missing


I installed the Android plugin for Eclipse Ganemede on Windows Vista
Home 32 bit.
When I try to create a new project, I don't see any available "Build
Target"s to select from, in the New Android project dialog. I can't
find the steps to create targets, if there are any.
How do i resolve this?
The installed software window in Eclipse does show Adroid DDMS and
Development tools, version 0.9.4.v20091022...4



2. Communicating with the GLSurfaceView.Renderer Thread

Hello again everyone... I hope this post meets the group a bit
faster... my last one took several days... and it seemed to join at
the same time as several other posts and was bumped to the second page
of posts before anyone could see it. I hope someone reviews posts that
haven't been responded to and tries to answer them...

Anyway, the docs mention using queueEvent(Runnable) and provides a
pretty simple example. In the samples provided with the SDK, there is
a TouchRotateActivity that creates a subclass for GLSurfaceView, and
nests the Renderer class inside. The value to be affected, the
rotation angle in this case, was made pulic in the nested renderer
class so it could be affected in by the touch event in the parent(?)

Was the second method done for something quick and dirty? Should I
possibly try something like this myself or would the smarter thing to
do be pursuing the queueEvent() method.

Thanks everyone,


3. android sdk, eclipse + OS X

4. How can I install android sdk on windows 7 x64?

5. Error::while building the SDK open source project

6. This class was probably produced by a broken compiler.

7. How to extract the .properties files in a third party jar file to apk file