Can I use the preview MemoryLayout/ValueLayout API, with its associated classes and interfaces, to adjust how float and double
do their arithmetic to results? I want to acheive something like the following:
where the Right Hand Side represents value formatting around the decimal/hexadecimal values around the dot separator point,
and the Left Hand Side represents floating point values themselves.
https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/foreign/MemoryLayout.html
I am having trouble working out and experimenting with this preview API. Is there someone on these forums who can tell me
if and how I can leverage this Java API so that I can systematically eliminate all base 10 and base 16 results from code like this:
?
do their arithmetic to results? I want to acheive something like the following:
Code:
float == [int].[int]
double == [long].[long]
where the Right Hand Side represents value formatting around the decimal/hexadecimal values around the dot separator point,
and the Left Hand Side represents floating point values themselves.
https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/foreign/MemoryLayout.html
I am having trouble working out and experimenting with this preview API. Is there someone on these forums who can tell me
if and how I can leverage this Java API so that I can systematically eliminate all base 10 and base 16 results from code like this:
Code:
public static void main (String ... args)
{
float a = 0.1F;
float b = 0.1F;
float c = a*b;
System.out.prinln(c); //should output 0.01 only.
double d = 0.1D;
double e = 0.1D;
double g = a*b;
System.out.prinln(g); //should output 0.01 only.
}
?