Re-FLOATING POINT VALUE CONVERSION.
Hi,
I have value lile this : 1.000000000000000E03, or 1.090000000000000E02 , is there
any function module to convert it into actual value like 1,00.00 or 1,099.00 etc.
Thanks in advance.
Shyam.
hi
call fm CONVERT_WITH_OVERFLOW_CHECK.
data lv_num type f .
data: p10_4(10) type p decimals 4.
lv_num = 27.
CALL FUNCTION 'CONVERT_WITH_OVERFLOW_CHECK'
EXPORTING
i_value = lv_num
I_UNIT = ' '
I_KRUND = ' '
IMPORTING
E_VALUE = p10_4
EXCEPTIONS
UNIT_CONVERSION_ERROR = 1
WRONG_E_VALUE_TYPE = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
the variable p10_4 will be having your result. its format will be driven by the type you have taken.
regards
Vishal Kapoor
Similar Messages
-
Precision loss - conversions between exact values and floating point values
Hi!
I read this in your SQL Reference manual, but I don't quite get it.
Conversions between exact numeric values (TT_TINYINT, TT_SMALLINT, TT_INTEGER, TT_BIGINT, NUMBER) and floating-point values (BINARY_FLOAT, BINARY_DOUBLE) can be inexact because the exact numeric values use decimal precision whereas the floating-point numbers use binary precision.
Could you please give two examples: one where a TT_TINYINT is converted to a BINARY_DOUBLE and one when a TT_BIGINT is converted into a DOUBLE, both cases give examples on lost precision? This would be very helpful.
Thanks!
Sunechokpa wrote:
Public Example (float... values){}
new Example (1, 1e2, 3.0, 4.754);It accepts it if I just use 1,2,3,4 as the values being passed in, but doesn't like it if I use actual float values.Those are double literals, try
new Example (1f, 1e2f, 3.0f, 4.754f); -
Hi all;
Please help.
I am getting floating point values in my source IDoc like 1.234- but while inserting into the ODS system i need the negative sign before 1.234.
How to achive this out.
NalinHi
You can achive this by using graphical mapping UUser defined function.
Mapping source fieldremove context UDF --- target field
UDF
for(int i=0;i<Float.length;i++)
if(Float<i>.endsWith("-"))
result.addValue("-"+Float<i>.substring(0,Float<i>.length()-1));
else
result.addValue(Float<i>);
Mudit
Award points if it helps -
Passing floating point values, but being recognised as doubles and int's?
Hi,
I was wondering how to differentiate between floating point values and ints etc
I am passing values into a public class with the parameters (float... values)
Public Example (float... values){}new Example (1, 1e2, 3.0, 4.754);
It accepts it if I just use 1,2,3,4 as the values being passed in, but doesn't like it if I use actual float values.
How come?
Cheerschokpa wrote:
Public Example (float... values){}
new Example (1, 1e2, 3.0, 4.754);It accepts it if I just use 1,2,3,4 as the values being passed in, but doesn't like it if I use actual float values.Those are double literals, try
new Example (1f, 1e2f, 3.0f, 4.754f); -
Right justification of floating point values
Hi all
i need to convert a incoming floating point value into (8.2) format i.e. (33678.9956 into 33678.99) i.e. spaces should be padded before if number of digits before decimal is less than 8 and i need to right justify all the incoming values..
pls help me in doing that through graphical mapping.Hi Barry,
sorry, the format given in the previous post is incorrect...
the required format is just opposite to that..i.e. all DOTS in the same column.
hope my requirement is clear..
Regards,
Manohar -
Easiest way to split a floating point value
Hello, I am trying to split a floating-point value (double) into its fractional and integer parts? I have been trying to find some sort of method in BigDecimal or Double that would do it but so far I haven't come up with anything. I know it could be done by searching through it as a String but that sounds like a very inefficent way to do it. I would appreciate any help you could give. Thanks
float f;
int i = (int) f;
float frac = f-i; -
Floating point format conversions
Hi All,
I have a binary file that has 8 byte floats in it written in VAX D floating point format. It also has 4 byte integers in it. I have to read this file on a Sun Sparc. To get the correct value of the integers I just swap the bytes around and write out the int value, so bytes 0123 get rearranged to be 3210 and then I use that as my int. I tried that with the doubles, reorder bytes 01234567 to 76543210 and then write out the double value but I don't get the value that was stored.
I read 8 bytes from the file, I'm supposed to get 512.0 but I get garbage.
The hex dump of the file shows: 0045 0000 0000 0000
I can't come up with a way to turn that into 512.0
Another one is 360448.0 with hex dump: b049 0000 0000 0000
Can anyone show me how to manipulate these bits/bytes to get the correct values?
ThanksHi Legosa,
Thanks for looking for a solution for me. The linkhttp://nicmos2.as.arizona.edu/thompson/kfocas/vax2sun.c
has a C implementation of exactly what I need and has saved me a lot of time and work. Translation to Java will have to use bit shifting I think, the C unions make for a nice implementation.
I also have to read PC and Cray generated files on my Sun.
I have found that, like the Vax, Intel x86 including pentium are all little endian and use IEEE so I'm guessing that I just have to do the byte swapping to translate from PC to Sun.
Crays are Big endian so I don't need byte swapping but I do need to do some manipulation of the exponent and the mantissa.
Do you know where I might find code that others have done for PC to Sun and Cray to Sun conversions of integers, floats and doubles?
BTW, for those who may read this later, the solution in vax2sun.c isn't quite right, the author forgot to use the least significant 32 bits and lost 3 bits in the middle but it is very close. To make it closer you have to change the vax2sun.c code a little.
Replace mantissa and lomant with
In union ieeebuf
int mantissa1:20
int mantissa2:3
int mantissa3:29
In union vaxbuf
int mantissa1:20
int mantissa2:3
int mantissa3:29
int lost_bits:3
In the code replace d.mantissa = v.mantissa/8 with:
d.mantissa1 = v.mantissa1
d.mantissa2 = v.mantissa2
d.mantissa3 = v.mantissa3
My few tests showed this gave very good results. The lost_bits are lost because ieee needs 3 more bits for its exponent so it doesn't have room for all of the vax mantissa bits. A little bigger range means a little less precision. -
Floating Point arithmetic conversion
Hi Everyone,
Can you tell me how to convert a floating point arithmetic field value to a currency field value.
thanks,
chanHi,
I hope simple move statement should work.
MOVE l_float TO l_curr.
Make sure that curr field has enough length.
Thanks,
Vinod. -
KF of type Floating Point Values
Hi
i had a KF of type Nubmer and data type FLTP-Floating point.
When i see the data loaded in the cube for that KF..
Sample values are '8,8310000000000000E-01' and '1,1690000000000000E-01'
What is E-01 mean and How can i intrept their actual values...
ThaksStill confused..
For better understanding...can please convert '8,8310000000000000E-01' and '1,1690000000000000E-01' for a number with 5 Decimal places or update me how to convert
Thanks -
How to read binary floating point values from TCP/IP
I am attempting to use a LabView application to read an array of binary single precision floating point numbers transferred through a TCP/IP connection from a Windows C++ program. The endianization occurs before the values are sent to the Labview application. When I read the values in LabView, some values are interpreted correctly, some are not. For instance, the C program is sending a 6 as one element, and 7 as another. Labview interprets both as 6. The difference between 6 and 7 in binary format is 1 bit (bit #21 if counting from 0 in LabView format). There are 2 other values that show the same error- 459.67 is being sent, 395.67 is read by labview (1 bit difference, exact same bit... 7.5 is being sent, 6.5 is being read by LabView (1 bit difference, exact same bit). LabView reads that bit as 0, when it should be 1.
This seems very odd to me because most values are being read correctly, including other values with that same bit on. There are values being read correctly that are both before and after the incorrect values in the array, so it's not just an issue with an offset or something in the bit stream. Additionally, when attempting to read an array of values with all bits on, I get a strange pattern of 111110011111100111111001111110.
We have also verified that the binary representation for the values is the same on both machines, once you account for the byte swapping. What am I missing here? How in the world can some values come across correctly and others incorrectly? Any help would be greatly appreciated! Our fallback is to transfer everything in ASCII, which is going to greatly increase packet sizes.
Thanks,
JasonUpdate:
Problem fixed. I say fixed and not solved because I don't know why it's fixed. I had been storing the TCP/IP read in a string and passing it through a shift register after each read. I would then concatenate it with the TCP/IP read result in the next loop. After each read, it would search the concatenated string for ASCII flags. When it found them, it would strip off the flags and then type cast the rest as single precision floating points.
I knew I would be getting the same number of bytes each time, so I ditched the ASCII flags and had just the binary values sent. This way, I expect to get all of the values in one TCP/IP read. No values are passed through a shift register to the next loop and there is no concatenation of the string outputs from TCP/IP read.
I'm not sure if it was the ASCII flags being included or something with the way I was manipulating the string that was causing the binary values to be interpreted incorrectly. Hope this helps someone else.
Jason -
JSlider with Floating point values
I desperatly need to create a JSlider with floating/decimal values. For example between 0 and 1 and ticks within an interval of 0.1.
The default behaviour of JSlider doesn't allow me to do so, hence is there any other way around ? I know it's possible to programmatically handle the required calculation by divding the values by 10, 100 or anything, but i want to display the actual values (floating/decimal) on the JSlider bar.
Thanks in advancethis might do you for the display
import javax.swing.*;
import java.awt.*;
class JSliderLabels extends JFrame
public JSliderLabels()
setLocation(400,200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JSlider slider = new JSlider(0, 100, 1);
slider.setMajorTickSpacing(25);
slider.setPaintTicks(true);
java.util.Hashtable labelTable = new java.util.Hashtable();
labelTable.put(new Integer(100), new JLabel("1.0"));
labelTable.put(new Integer(75), new JLabel("0.75"));
labelTable.put(new Integer(50), new JLabel("0.50"));
labelTable.put(new Integer(25), new JLabel("0.25"));
labelTable.put(new Integer(0), new JLabel("0.0"));
slider.setLabelTable( labelTable );
slider.setPaintLabels(true);
JPanel jp = new JPanel();
jp.add(slider);
getContentPane().add(jp);
pack();
public static void main(String[] args){new JSliderLabels().setVisible(true);}
} -
Rounding a floating point value
How can I set the precision of a float, I want to express a dollar amount using a float, so I need to set the precision to two places past the decimal point, but am unsure of how to do so... hopefully this isn't a stupid question.
thanks!would this be accomplished by calling the toString of a Float? I have a primitive type float, and I don't see any methods or constructors in the DecimalFormat class that can handle a float as a parameter...
-
Compare floating point values in a column
I have a column defined as NUMBER. The values are say 1.2345 and 1.23443. Visually i can say they are almost the same but if i do select count(distinct colA) from table it gives two values, which is perfectly right. What i want to do is say if they are less than 0.0001 then count them as same value.
You could argue if i use ROUND or TRUNCATE to the 'n' decimal point but i see this as an issue even even to two decimal places. If the 3rd digit after the decimal is greater than 5 it would round the 2nd digit. If i use TRUNCATE to 'n' places then the last digit might be smaller than the previous value so again the same issue.
However, my problem is how do i do if its in 2 or 3 different rows for the same column. If they are in two columns, i am able to do (COLA - COLB) and if the value is < 0.00001 then ignore or filter from the query result.
Example:
ColA , ColB
Variable1, 1.23453876
Variable1, 1.2342736
Variable1, 1.23420087
Variable2, 10.250
Variable2, 15.775
Variable3, -1.93815994262695
Variable3, -1.93815803527832
Output: Count of unique values for each variable in columnA
Variable1, 1
Variable2, 2
Variable3, 1
OR
Output: Display on those variables whose values is more than 0.0001 (4 digits after the decimal)
Variable2, 2
I am using oracle 10.2 Enterprise Edition and accessing data via TOAD
ThanksPeter,
Thank you for the sql, i had not tried lag function before so it was new to me. I modified it slightly to lag by 'partition query'. The issue i see is it does delta between only two consecutive values so if there are 5 values in 5 rows then they can be off by 0.0001 (some small number) and we will never catch those variables because the case statement would evaluate to '0' based on the if condition.
However, for my case it would work perfectly fine since i wanted to separate small values from the real obvious big deltas. As in the case below where the delta was 5.XX which narrows down to Variable2.
with
tab as
(select 'Variable1' cola, 1.23453876 colb from dual union all
select 'Variable3', -1.93815994262695 from dual union all
select 'Variable1', 1.2342736 from dual union all
select 'Variable2', 10.250 from dual union all
select 'Variable2', 15.775 from dual union all
select 'Variable1', 1.23420087 from dual union all
select 'Variable3', -1.93815803527832 from dual union all
select 'Variable4', 47.41209 from dual union all
select 'Variable4', 47.41207 from dual
select *
from
select
cola,colb,lag(colb) over (partition by cola order by colb)prev_value, round(abs(colb - lag(colb) over (partition by cola order by colb)),4)prev_delta
,case when colb - nvl(lag(colb) over (partition by cola order by colb ), colb) < 0.0001 then 0
else 1 end dif_count
from
tab
--order by cola
--group by cola
COLA COLB PREV_VALUE PREV_DELTA DIF_COUNT
Variable1 1.23420087 0
Variable1 1.2342736 1.23420087 0.0001 0
Variable1 1.23453876 1.2342736 0.0003 1
Variable2 10.25 0
Variable2 15.775 10.25 5.525 1
Variable3 -1.938159943 0
Variable3 -1.938158035 -1.938159943 0 0
Variable4 47.41207 0
Variable4 47.41209 47.41207 0 0
You guys rock! thank you. -
How to convert PM Module Breakdown Duration (AUSZT) floating point value into Minutes
Hi Frnds,
My requirement is to display a normal alv report. Out of which one of the filed is from VIQMEL-AUSZT (Breakdown Duration).
Which is of Data type FLTP.
Details:
AUZTV
AUZTV
TIMS
6
Start of Malfunction (Time)
12:39:19
AUZTB
AUZTB
TIMS
6
End of Malfunction (Time)
12:42:00
AUSZT
AUSZT
FLTP
16
Breakdown Duration
1.6100000000000000E+02
Now I want to convert the value '1.6100000000000000E+02' into Minutes.
Kindly let me know the solution.
Note: I tried with standard FM 'PM_TIME_CONVERSION' and converted the break down value into hours.
For example: 1.6100000000000000E+02 to 4,472222222222222E-02.
But i want to convert the break down duration value into perfect minutes.
With Regards,
Sudhir.Simply equate to a variable of type P decimals zero. It should give you value in seconds. Divide it by 60 to have it in minutes.
-
How can I get a floating point value from Labview 6 into VB 6
I need a numeric value from Labview and use it in my Visual Basic program. How can I do that...
ThanksHello jardinpaul,
You can use Visual Basic to call a LabVIEW DLL that you create from your LabVIEW VI. Take a look at this example on our website:
Using Microsoft Visual Basic to Call LabVIEW DLLs That Pass Numeric Data Types
David McClelland
NI Applications Engineering
Maybe you are looking for
-
RFC connection error between BW 3.5 and ECC 6.0
Hi gurus, We've defined an RFC destination between BW 3.5 and ECC 6.0. Connection test (SM59) is ok, but authorization one fails and ALEREMOTE users block. These users on both systems have good profiles. We look ST22 and find a runtime error on CALL
-
How do I fix this problem?? I received this Error Message while trying to install on my netbook again. (Service 'Apple Mobile Device' Failed to start. Verify that you have sufficient privileges to start system services. I had Itunes on already but
-
Java Script Errors on Siebel Sales and Call Center Login Pages
Hello, This only happens with some users, but not all of them. When we first open the login screen in TRIAL we get several Internet Explorer errors. 1. Line: 1153 Char: 16 Error: Expected ')' Code: 0 URL: http://topaxsear009.iss.bnr.com/callcenter_en
-
Suppress ALV statistics in background
Hi, When I execute an ALV report in background, it is displaying the sort options and report statistics. However, it does not happen in foreground. Is there any way to suppress this? Thanks.
-
I blocked video in website, how do I unblock?
I mistakenly blocked a video on http://www.filmtotaal.nl/filmsoptv.php (I thought I was blocking an ad); now I can't play any video from that site. How do I unblock?