Convert Decimal to Hex
I use an LDAP database that stores values in decimal format,
but to display these values to the end user, I want them in Hex.
For example.
50699 becomes C60B
and
18743297 becomes 11E0001
Is there a function built into CF that allows me to do this
conversion? I can't seem to find one. Or will I have to write a
cfscript or javascript function to do this for me?
-xtort
> I just found that in Ben Forda's book. That got it,
thanks!!
Glad you found it.
livedocs is a good resource for those who are patient: it's a
*very* slow
site, especially given the simple pages it's delivering. But
it's got
everything you need (the annotations on the pages are often
more useful
that the "official" line, btw).
A good entry point to the most important parts of livedocs
are these:
http://ray.camdenfamily.com/downloads/functions.html
http://ray.camdenfamily.com/downloads/tags.html
It cuts down quite a bit of the waiting. They;re also good
lists to scan
to get a handle on what CF can do, at least at an executive
summary level.
Adam
Similar Messages
-
Exception occuring while i'm trying to convert decimal to Hex
Hello all you genius people, please help me out. I'm using this simple code(given below) to read String from a file then convert it to Hex and write in anoher file. But i'm getting this exception that, after reading few lines it gives such exception:
java.lang.NumberFormatException: For input string: "2826111134"
import java.io.*;
public class DecimalToHexConv {
String line;
String hexEsn;
String temp;
int esn=0;
public DecimalToHexConv(){
try{
FileWriter fwr = new FileWriter("CTGHLR201005_out.txt");
BufferedReader bfr = new BufferedReader(new FileReader("testin.txt"));
while((line=bfr.readLine())!=null){
line= line.replace('|',';');
String spl[] = line.split(";");
esn = Integer.parseInt(spl[2].toString().trim());
hexEsn = (Integer.toHexString(esn)).toUpperCase();
temp= spl[0]+"|"+spl[1]+"|"+hexEsn+"\n";
System.out.print(temp);
fwr.write(temp);
fwr.close();
catch(Exception e){
System.out.println("Exception: "+e);
public static void main(String[] args) throws Exception {
DecimalToHexConv dtc = new DecimalToHexConv();
}output:
4702181500|11800467|2FA42C8B
4702825345|11704172|620A4CFC
4703200000|11200000|52B53DB9
4703200001|11200001|52156AC7
Exception: java.lang.NumberFormatException: For input string: "2826111134"
testin.txt:
4702181500|11800467|799288459
4702825345|11704172|1644842236
4703200000|11200000|1387609529
4703200001|11200001|1377135303
4703200046|11200046|2826111134
4703200000|11200000|1387609529
4703200001|11200001|1377135303
So after converting first 4 lines i got the exception. Please hep me out.. that what is wrong???
Regards
SahrearBut i'm getting this exception that,
after reading few lines it gives such exception:
java.lang.NumberFormatException: For input string:
"2826111134"It's because the biggest number an int can hold is 2147483647. You can use long insted. It can hold bigger numbers but understand that it has an upper limit too. -
Does any one have any code snippet to do this in Java ?
one of the applications that i am building has the need to convert an incoming decimal value from a backend system to hex and take the last 2 fields of the hex value for some comparison checking.
All help is deeply appreciated ..
thanks
Roxone of the applications that i am building has the
need to convert an incoming decimal value from a
backend system to hex and take the last 2 fields of
the hex value for some comparison checking.In an int representation of a number each hex digit will occupy 4 bits, so
int i = ....; // decimal number
int h1 = i & 0xf; // first hex digit from the right
int h2 = (i>>>4) & 0xf; // second hex digit -
Function for converting Decimal to HEX
Does anyone know of such a function?
Thanks. We are still a bit confused. I have attached an email from a data supplier of ours. Can you make sense of it ???
Page 24 says: if the bit 3 (0x08) of the field TF_FIELD_STATIC_SEC_FLAG is 1 for an US stock,
then the stock is constituent of the NASDAQ 100 index NDX.
Example:
For Microsoft (MSFT) the field TF_FIELD_STATIC_SEC_FLAG has the value
0x39 = 57 = 0x01 + 0x08 + 0x10 + 0x20
because MSFT is constituent of the
Dow Jones Industrial index !DJI (0x01)
NASDAQ 100 index NDX (0x08)
S&P 100 index OEX (0x10)
S&P 500 index SPX (0x20) -
Hello,
sorry but i have a simple question. I want to convert decimal number 0-10000 (like 10000 (decimal) to 27 and 10 (hex) or 1000 (decimal) to 03 and E8 (hex)) to two hex numbers and back. Iám searching for an easy way.
I tried different ways but i can`t find a solution.
greetings Schwede
Message Edited by Schwede on 12-10-2008 07:11 AM
Solved!
Go to Solution.A very quick an easy method. For numbers go to palette numeric>>data manipulation>>join numbers and split numbers
Message Edited by t06afre on 12-10-2008 07:59 AM
Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Attachments:
sample.vi 34 KB -
I've been banging my head against the desk for hours on this one. I really need to write a Java applet to convert decimals to hex, I really would appreciate any help given with this one. So far I only have this;
value1 = (decimal % 16);
problem is, I don't know how to get the value and then do the calculation again. I know that I should be using some sort of do/while loop, with a while(somevalue!=0) at the end, but thats about it.I can do it easily using a pen an paper.
Get the decimal number e.g 50
Divide it by the hex base 16, equals 3 remainder 2
Divide 3 by 16, equals 0 remainder 3
the answer is the two remainder from the bottom added, 32.
The problem I'm having is that I don't know how to get the new value i.e 3 and then divide it by 16, and then if required, divide it by 16 again. I'm not to worried about converting A to 10 and such yet, I just need help getting the value and dividing it by 16 over and over and then recording each the answer each time. -
Converting BLOB to HEX and HEX to BLOB
Hi!
I have a table that stores pictures as BLOB. Due to some project rules, I need to be able to convert this image to a CLOB (represented as a HEX String) and, after that, I need to convert this HEX String back to BLOB.
I already created the function that converts BLOB to HEX. See below:
CREATE OR REPLACE FUNCTION blob_to_hex (blob_in IN BLOB)
RETURN CLOB
AS
v_clob CLOB;
v_varchar VARCHAR2(32767);
v_start PLS_INTEGER := 1;
v_buffer PLS_INTEGER := 32767;
BEGIN
DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);
FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(blob_in) / v_buffer)
LOOP
v_varchar := DBMS_LOB.SUBSTR(blob_in, v_buffer, v_start);
DBMS_LOB.WRITEAPPEND(v_clob, LENGTH(v_varchar), v_varchar);
v_start := v_start + v_buffer;
END LOOP;
RETURN v_clob;
END blob_to_hex;But, I´am having some difficulties to convert the HEX CLOB back to BLOB.
Does anybody know how could I do this?
Thanks a lot!!!
Registry this procedure
first create directory BLOB_DIR
CREATE OR REPLACE DIRECTORY
BLOB_DIR AS 'C:\temp';
CREATE OR REPLACE PROCEDURE BLOB_LOAD(filename varchar2)
AS
lBlob BLOB;
lFile BFILE := BFILENAME('BLOB_DIR', filename);
BEGIN
INSERT INTO O_CONTRACT_IMAGES
(CONTRACT_NO,CONTRACT_Year,CONTRACT_blob)
VALUES (1,2, empty_blob())
RETURNING CONTRACT_blob INTO lBlob;
DBMS_LOB.OPEN(lFile, DBMS_LOB.LOB_READONLY);
DBMS_LOB.OPEN(lBlob, DBMS_LOB.LOB_READWRITE);
DBMS_LOB.LOADFROMFILE(DEST_LOB => lBlob,
SRC_LOB => lFile,
AMOUNT => DBMS_LOB.GETLENGTH(lFile));
DBMS_LOB.CLOSE(lFile);
DBMS_LOB.CLOSE(lBlob);
COMMIT;
END;
Edited by: Hossam Kasem on 20-Apr-2011 05:56 -
How to convert decimal notation to comma notation
Hi Folks,
I have an issue in converting decimal notation to comma notation for France.
I have changed the decimal notation in SU01 from 123.4 to 123,4 but when i run some custom program written by me it is extracting output as 123.4 than 123,4.
So i want to have the output of report to conver all numerical values(from decimal format to comma format) i.e., 123,4 format from the 123.4 format.
Please help me in fixing this issue
Edited by: Nishanth Kumar Reddy Chenchu on Apr 24, 2008 1:16 PMHi Nishant,
U can use the statement WRITE TO. This will write the data as per the user settings. When ever user changes his settings like decimal notations then this statement will write the data as per the current settings of the user.
DATA: l_amount1 TYPE wrbtr VALUE '123.45',
l_amount(16) TYPE c.
WRITE:/1 l_amount1.
WRITE l_amount1 TO l_amount.
WRITE:/1 l_amount.
Just copy paste above code in a sample program. First execute this program and note the output. Then change the user settings for decimal notations and log of from SAP(Because user settings will become active only after fresh login). Now execute ur report and see the difference. In this way u no need to change the program when ever user changes his settings.
This thing not pnly applies for amount but also for date, time Quantity fields
Thanks,
Vinod -
How to convert decimal numbers to Hours and minutes
Hi,
I am using SSRS 2005. I want to convert decimal numbers to Hours and minutes.
Say suppose, I am adding daily work hours and minutes and the total is 208.63.
Here 208 hrs and 63 minutes. How to convert this to 209 hrs 03 minutes in SSRS.
Any In-built function is there? or how to do using custom code?
Appreciate your help.
Regards,
Balasuppose if field name is TotalDailyHours you can do it as below
=CStr(Cint(Floor(val(Fields!TotalDailyHours.Value)) + ((val(Fields!TotalDailyHours.Value)-Floor(val(Fields!TotalDailyHours.Value)))*100)/60)) + ":" +
Right("00" +Cstr(Cint(((val(Fields!TotalDailyHours.Value)-Floor(val(Fields!TotalDailyHours.Value)))*100) Mod 60)),2)
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
JMS Correlation ID not converting to EBCDIC Hexa
We are using the PI 7.1 system on a AIX platform.
We use the JMS adapter to send messages to a MQ Queue manager on a AS400platform.
WebSphereMQ transport protocol is in JMS adapter.
We are generating custom dynamic correlation id using a UDF.
Expectation is to receive the correlation id in Ebcdic format because the
receiving end is a AS400 system.
But what I receive there is a Ascii Hexa.
For a example we are sending the correlation id as 0180000012. (ASCII)
What MQ receive is 30313830303030303132 (ASCII HEX)
Where what MQ should receive is F0F1F8F0F0F0F0F0F1F2 (EBCDIC HEX)
I need help to find out why JMS adapter is converting the correlation id
in to ASCII HEX without converting to EBCDIC HEX.
Appreciate a lot if any one can provide some help on this.
Thanks a lot,
Tania.I am not sure if I have understand the issue correctly.
Do you create an ASCII string and the ASCII characters are not converted into EBCDIC,
or do you create a HEX String?
Or does the JMS adapter converts your ASCII string to Hex?
I have the impression that the behaviour is a design gap, which nobody has noticed before.
A work around could be in converting the ASCII to EBCDIC inside the UDF,
Report this to SAP -
How to convert signed ascii hex to float value
Hi,
I have a requirement to convert IEEE ascii hex to float value.
Following code is working for +ve float value but it didn't work for -ve.
public static float hexToFloat(String str){
float floatVal= 0.0f;
int decimalValue =Integer.parseInt(str,16);
floatVal=Float.intBitsToFloat(decimalValue );
return floatVal;
for example "BE4CE1E6" should return -0.20 . (i verified in http://babbage.cs.qc.edu/IEEE-754/32bit.html )
For the above string I am getting number format exception.
pls help me.The problem is the parseInt method. It can only process numbers up to 2147483647 or 7FFFFFFF. Because that method expects a signed number.
The solution is to use Long.parseLong() instead.
public static float hexToFloat(String str){
float floatVal= 0.0f;
int decimalValue =(int)Long.parseLong(str,16);
floatVal=Float.intBitsToFloat(decimalValue );
return floatVal;
} -
Hi I would like to know if you can convert decimal to binary using actionscript 3.0?
Hi I would like to know if you can convert decimal to binary using actionscript 3.0?
Hi thanks for the response Ive tried to implement the code as you stated but it is not outputting please if you could check the following code and let me know where Ive gone wrong that would be much appreciated Thanks!.
miles_txt.addEventListener(KeyboardEvent.KEY_DOWN,convertKilometres);
miles_txt.restrict ="0-9";
function convertKilometres (k:KeyboardEvent):void {
var miles:Number;
var kilometres:Number;
if (k.keyCode == Keyboard.ENTER){
miles=Number(miles_txt.text);
kilometres=miles* 1.609344;
kilometres_txt.text = kilometres.toPrecision(2);
kilometreConvert_txt.addEventListener(KeyboardEvent.KEY_DOWN,convertKiloToMile);
kilometreConvert_txt.restrict = "0-9";
function convertKiloToMile(k:KeyboardEvent):void{
var kilometreConvert:Number;
var milesAnswer:Number;
if (k.keyCode==Keyboard.ENTER) {
kilometreConvert=Number(kilometreConvert_txt.text);
milesAnswer=kilometreConvert* 0.621371192;
milesAnswer_txt.text = milesAnswer.toPrecision(2);
binary_txt.addEventListener(KeyboardEvent.KEY_DOWN, checkEnterKey2);
function checkEnterKey2(e:KeyboardEvent):void{
if(binary_txt.text != '' && e.keyCode == Keyboard.ENTER){
decimal_txt.text=binaryToDecimal(binary_txt.text).toString();
function binaryToDecimal(s:String):Number{
var n:Number = 0
for(var i:int=0;i<s.length;i++){
n+=Number(s.substr(i,1))<<(s.length-1-i)
return n;
function decimalToBinary(n:Number):String{
return n.toString(2);
return_btn.addEventListener(MouseEvent.CLICK, goBackToCalculator);
function goBackToCalculator(e:Event):void
mybuttonSound.play();
gotoAndStop("Calculator");
clear_btn.addEventListener(MouseEvent.CLICK,clearField);
function clearField(e:MouseEvent):void{
mybuttonSound.play();
miles_txt.text ="";
kilometres_txt.text ="";
milesAnswer_txt.text ="";
kilometreConvert_txt.text ="";
binary_txt.text ="";
decimal_txt.text =""; -
Nesting CONVERT(DECIMAL)
SUM(CONVERT(DECIMAL(12,2),CONVERT(DECIMAL(12,2),DATEDIFF(mi,StartTime,FinishTime))/60) - ISNULL(Breaks,0))
From the query above, I had to nest Convert decimal twice before getting the result. What is the logic behind this sort of query? I got the result I wanted but I want to equally know the reason for having decimals repeated the way I just did.
Thank you.
ZionliteHi Yookos/Zionlite, It looks like Himanshu explained as shown below, the third one. Am not getting what you are trying..Please eloborate.
>>>SELECT
CONVERT(DECIMAL(12,2),DATEDIFF(mi,GETDATE()-3,GETDATE()))
-- 4320.00
SELECT
CONVERT(DECIMAL(12,2),DATEDIFF(mi,GETDATE()-3,GETDATE()))
/60
--72.000000
SELECT
CONVERT(DECIMAL(12,2),CONVERT(DECIMAL(12,2),DATEDIFF(mi,GETDATE()-3,GETDATE()))
/60)
--72.00 -
Hi all,
How to convert decimal type length 3(e.g:25.0) to char type.......
Thanks in advancehi,
data : var_dec type p decimals 3,
var_char(10).
<b>move var_dec to var_char.</b>
else use FM
CALL FUNCTION <b>'CEVA_CONVERT_FLOAT_TO_CHAR'</b>
EXPORTING
FLOAT_IMP = P_ORIGEN
FORMAT_IMP = CAMPO_FLOAT
IMPORTING
CHAR_EXP = C_DESTINO.
Regards,
Santosh -
Checking and Converting binary, octal, decimal, and hex
Hi,
I have a classroom project which will need to validate that data entered in a text is of a certain type with a keyListener, and then convert that value to the other 3 types.
I know character.isDigit will handle the decimal case, and that I can then use Integer.otString methods to convert to binary, octal, and hex, but what about the other cases?
ThanksOK, this isn't working. If I've already established
that the string entered into, for example, the
integer-only textfield is a valid integer, I should be
able to simply use integer.parseint(s, 2) to convert
it into binary, right?Not exactly. You should be able to use Integer.parseInt(s, 2) to return the result of converting it from binary representation. You appear to think that this affects whatever "s" refers to, which is not the case. Note also, that method returns an int which is the decimal value in question.
When you are thinking of int variables, be careful not to think of them as "decimal" or "binary". They are neither. They are just numbers. "Decimal" and "binary" are text representations of numbers, so those concepts can only be applied to strings.
Integer.parseInt(s, 2);
txtBin.setText(s);So here you want to assume that the input is a string that represents a number in decimal, and you want to find the string that represents the number in binary. Like this:// convert string in decimal representation to number
int dec = Integer.parseInt(s);
// convert int to binary representation as string:
String binary = Integer.toBinaryString(dec);
// write that to the text field
txtBin.setText(binary);You could use a one-liner to do that, but you'll need the "dec" variable to set the other text boxes.
Rembering why I hate OO...All of what I said there is true in just about all computer languages, OO or otherwise.
PC²
Maybe you are looking for
-
How many shows can you record at one time?
I have the CHS435HDC and I was talking to the rep and he thought it was 7 shows at one time....being a previous tech rep from the 'other guy', I know the standard is two shows at once and watching one of the other, nothing beyond those two..... Anyon
-
HT1296 how do i sync contacts from iphone to itunes
Attempting to reset iphone, I need to save contacts to itunes account
-
Help!! My kid was on iChat - can I find a copy of the chat??
If a Chat is not saved before the chat ends on 3.1.8 (v445), is there a copy of the chat on the computer? Thanks for a quick response.
-
Spotlight Search stopped working on my 4s
Spotlight Search stopped working on my iPhone 4s. Apple replaced my 4s 2 days ago and now spotlight search has stopped working on the 2nd 4s. The Apple techs are stumped, any ideas?
-
I am trying to merge an iTunes track into the audio on a piece of footage but I want the iTunes track to start at a certain point not at the begining. I want to fade out the original audio and fade in the iTunes track starting a minute or so in. Can'