Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How does one enter a negative DOUBLE/SINGLE constant in XB?

constant double enter negative xb
0
Posted

How does one enter a negative DOUBLE/SINGLE constant in XB?

0

It takes a little work to determine the value, but you would enter it as a “DOUBLE image” preferably. A DOUBLE image is more accurate than entering the decimal anyway. It is written as the prefix “0d” followed by 16 hex digits. A good example can be found in the xma.dec file (which is the file you see in the PDE by selecting help|math). Towards the end of that file, after the function declarations, mathematical constants such as $$PI and $$E are declared. $$PI = 0d400921FB54442D18 In order to determine the representation of a particular DOUBLE value, you would have to use DHIGH and DLOW to convert the binary representation into two XLONG values, then convert those into two hex strings. Example: FUNCTION DoubleImage$ (DOUBLE x) xhigh = DHIGH(x) xlow = DLOW(x) RETURN (“0d”+HEX$(xhigh, 8)+ HEX$(xlow, 8)) END FUNCTION x# = -1.2345 d$ = DoubleImage$ (x#) PRINT x#, d$, DOUBLE(d$) This gives us the following results: -1.2345 0dBFF3C083126E978D -1.2345 So we can define our constant for -1.2345

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123