Convert hex to Decimal and keep leading zeros..
Hi,
I hope you can help?
How to convert hex to Decimal and keep leading zeros
I read 002C, hex, and I want to convert it to 0044 decimal.
sscanf (MyNum, "%4x", &DecNum); will only give me 44.
It have been working up till I started to get leading zeros.
We will always have a 4 digit hex input in a range
We must have the leading 00 in this case.
How is this best done?
Thanks for the help
Simon
Solved!
Go to Solution.
Hi,
I don't really understand your problem. Is this stuff what you need ?
int main (int argc, char *argv[])
const char MyNum[] = "002C";
int DecNum;
sscanf (MyNum, "%4x", &DecNum);
printf ("%04d", DecNum);
getchar ();
return 0;
"0044" appears on standard output when printf function executes...
Similar Messages
-
Help keeping leading zero String- Long
Hello
I wonder lets say I have a String "09090" how do I convert this String to a Long and keeping leading zero so the Long is 09090?
/D_SNumeric types like Long (or long) are numbers, not strings, so they have no formatting notions like leading zeroes. If you want to maintain the string "09090" keep the string around, even if you have to parse it as well. By the way, you forgot to describe what your goal is, what you are trying to do and what it has to do with leading zeroes.
One more: Why does this print false?
System.out.println(07070 == 7070);Hint: this generates a compile-time error:
System.out.println(09090 == 9090); -
How to keep leading Zeros in a CSV file
Hi All -
I am trying to keep leading zeros in CSV file. Ex. I need 00001 but not just 1. I tried formatting the cells but not getting saved. Any advise please.
Thanks.Dear Super Man ,
Try using ALPHA Conversion Routine
ALPHA Conversion Routine
The ALPHA conversion is used in the BW system for each presetting for character characteristics. The ALPHA conversion routine is registered automatically when a characteristic is created. If you do not want to use this routine, you have to remove it manually.
The ALPHA conversion routine is used, for example, with account numbers or document numbers
For more details
http://help.sap.com/saphelp_nw04/helpdata/en/9b/f9c18f5a07f0459127e9676ae22a54/frameset.htm
Hope it helps
Regards
Bala -
How do I convert .txt to .pdf and keep the formatting
I have a large .txt file that I would like to convert to .pdf. I have tried to print the file and choose Adobe PDF but the output is just a mess. I loose all the formatting and get blank pages every so often. Does anyone know if is possible to convert .txt to .pdf and keep the formatting. I would try a virtual printer application but I am not able to just install any application on my office computer. Any help would be greatly appreciated.
It may be a bit late for you now but in future (and for anyone else interested) I would recommend copying the text into a word document and changing the text font to Consolas. Adjust the size to fit the page again and it should match the original notepad formatting.
-
How to delete decimal point and adding leading zeros....
Hi,
I have one requirement in the report i.e.
<b>Present Value :</b> 44567.98
<b>Expected Value :</b> 0000004456798
In the present Value how will I remove that decimal point and how to add those six ing zeros. I tried with CONVERSION_EXIT....but it is not giving. Help me...
Thanks in advance.
Regards,
Kumar.Hi,
Use SPLIT and COMCATENATE fnctions.
Eg: split l_v at '.' into l_v1 l_v2
concatenate l_v1 l_v2 into l_v.
For adding leading zeros
Use FM CONVERSION_EXIT_ALPHA_INPUT.
Eg:
data: tknum type vttk-tknum value '99156'.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = tknum
importing
output = tknum.
Sri
Message was edited by:
Sri Tayi -
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² -
Counting decimal numbers remove leading zero
Hello:
I'm counting numbers down using the Numbers effect, from 1 dollar down to .77, but I don't want a leading zero. I have it set to two decimal places but it keeps the zero and shows it as 0.77.
Is there a way to get rid of the zero?You could just mask it out after splitting the layer suitably? Otherwise this is still a good alternative:
Dan Ebberts's Expressioneering Design Guide
Mylenium -
Keeping leading zero intact in mail attachment
Hi All,
I am sending the excel document into recipients mail id but the leading zero's in the data get truncated.
I have read so many posts in the forum but did not find any answer to get this done. Some trails i did as follow:
1. Adding apostrophes ( ' ) doesn't satisfy my requirement.
2. Data is good before passing it to mailing function module.
3. All function module i have tried like SO_NEW_DOCUMENT_ATT_SEND_API1, SO_DOCUMENT_SEND_API1 etc.
None of them satisfy my requirement.
Can someone tell the exact solution?
Thanks in advance.
Rudhir BhaskarThat's not an SAP email issue though. I'm sure you'll find that if you open the sent file from a text editor, either from the email client directly or after saving it, that the leading 0's are intact. Excel is simply interpreting the field as a numeric field upon opening and dropping them. You need to run the text import wizard and specify the fields as text in order to keep them.
-
Hi all,
Iam having a requirement where in a enduser enters the vendor number and after pressing enter key it should display the vendor num along with vendor name concatenated in the same field. But the end user is provided the facility that he may not enter the exact vendor number ( I mean if vendor number is for example 0000055, the enduser may enter simply 55). The system should convert it with leading zeroes internally. And in display it should display removing leading zeroes.
like input: 55 output : 55 Vendor_Name
my approach
iam using conversion_exit_alpha_input for adding leading zeroes before select query ( to fetch the vendor name for vendor number the user supplies)
before displaying the output after concatenation,
iam using conversion_exit_alpha_output.
after execution,
it is asking the exact vendor number . But in the output, it is giving the vendor number along with vendor name by removing leading zeroes ( as expected).
how to make the system accept the number without leading zeroes. please suggest me.
tthanking you in advance
regards
BikashHi Bikash,
Since you have to display the Vendor number concatenated along with the Vendor Name, why do you need to use the Alpha Exit Function Module. As you have the Vendor number without the zeros in the input field, you can store it in a temporary variable and then once the Vendor name is available you can concatenate it along with the number in the same field.
If you need a code snippet, you can provide the Technical details of the fields of input. We can use the implicit ABAP type casting feature to get the Vendor Number without any leading zeros.
Hope this helps.
Thanks,
Samantak. -
Keeping leading zero of an integer
Wondering if anyone can help me solve this small problem.
Here's what I had:
for(int i=01; i<13; i++) {
String month = "2003" + i;
System.out.println(month);
}This gives me the following output:
20031
20032
20033
20034
20035
20036
20037
20038
20039
200310
200311
200312
However, I want the output to be:
200301
200302
200303
200304
200305
200306
200307
200308
200309
200310
200311
200312
Then I tried this:
String year = "2003";
String month = new String()
for(int i=01; i<13; i++) {
if(i<10)
month = year+"0"+i;
else
month = year+i;
System.out.println(month);
}The code above gives me the results I want. However, I'm thinking that there has to be a better way to do this. Is there anyway to increment the variable i and kept it two digits? I mean keeping the leading zero until it gets to the number 10? Any ideas?the previous poster is right. It's also a little odd how you have things setup, in that you're expressing dates with an unusual approach (most people would use Date or Calendar), but, if you want to keep like you have it, I think this might be the easiest solution:
int date = 200300;
for (int i = 1; i < 13; i++ ) {
System.out.println(date + i);
} -
Keeping leading zeroes in flat file
I am loading data from a flat file to a DSO.
One of the columns in the flat file is data type CHAR with a length of two. The data values will be either 01, 02 or 03.
When I load the data, the leading zeroes are dropped. Thus, I see 1, 2 and 3 in my DSO. How can I prevent this happening?Hi,
Right Click on that column in Excel file and Formate Cells >Custome> Under Type give "00" and then give the values in column like 01 , 02 .... and save as .csv and close it, immediatly load it, DON"T OPEN FILE, because , if you open it will reset to 1, 2... SO again you need to Right click.....and formare cells..
Thanks
Reddy
Edited by: Surendra Reddy on Jun 24, 2010 4:28 PM -
How to remove pound symbol # and preserve leading zeros in BEx Query
Hi,
I have two questions regarding the display in BEx Query.
1. How can I remove the pound symbol # for blanks in BEx Query?
2. How can I preserve leading zeros? At the moment, value "001" will be displayed as "1". But I need the leading zeros.
Thanks.
JoonHi ,
You can apply these settings in Bex query designer.
If you need to remove pound symbol jsut make a new formula and use NODIM function you will find this function under data functions.
So NODIM(Your price keyfigure) this will remove the Pound symbol.
For # just find out against which characterstic you are getting # then go to default values panel there you will find all your characterstic which you are using in report---Rt click -Restrict-single valuesdirect input-#-Move to selection(That forward arrow)--select that # and choose exclude from selection (That red square icon).
And yes for leading zeros check out this thread
Leading zeros not displaying
Hope it helps you.
Regards,
AL
Edited by: AL1112 on Jun 9, 2011 1:43 PM
Edited by: AL1112 on Jun 9, 2011 1:47 PM -
I have a series of reports that use Account segmentations that are based on a string of numbers. Unfortunately some of these strings of numbers have leading zeros. (eg. 0023, 0123)
When the reports are downloaded to excel these leading zeros are lost. Any words of wisdom on how to keep these leading zeros in the report when downloading to excel?How would I put the value into double quotes?
Would this be done under Edit Column Formula?
If so, I must be doing something wrong. The current column formula is:
Campaign."Source Code"
If I change it to:
"<Campaign."Source Code">"
I get the following error.
[nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <Code>: Syntax error [nQSError: 26012] . (HY000)
SQL Issued: SELECT "<Campaign."Source Code">", Campaign."Campaign Name", Campaign.PICK_0, Campaign.PICK_1, Campaign.PICK_2, Campaign.PICK_3, Campaign.PICK_4, Campaign.PICK_5, Campaign.PICK_6, Campaign.PICK_7, Campaign.PICK_8, Campaign.PICK_9, Campaign.Status, Campaign.TEXT_31, Campaign.TEXT_32, Campaign.TEXT_33, Contact."Contact First Name", Contact."Contact Last Name" FROM "Campaign Response Analysis"
Please advise. -
Export jsp content to Excel -- how to keep leading zero?
Hi:
I am trying to export a JSP content to Excel by using
response.setContentType( "application/vnd.ms-excel" );
response.setHeader( "Content-disposition", "attachment; filename=pc.xls" );
it was working great except my jsp has a field whose value consist of leading zero. i.e. 000XXX. Excel strips the leading zero, but I would like to keep them. Please advise.hi Chang,
Can you please check my thread http://forum.java.sun.com/thread.jspa?threadID=737238&tstart=0
I think you might know the answer since it is similar functionality but for text files.
Thanks ! -
How to keep leading zeros using SAP_CONVERT_TO_XLS_FORMAT
my leading zeros drop when download using FM-SAP_CONVERT_TO_XLS_FORMAT, how to fix it?
Hi,
You can try as below.
Let's for the 10 digit numeric field, using the function module CONVERSION_EXIT_ALPHA_INPUT, you can get the 10 digit number with leading zeroes.
Now if you declare the char of 10 in length field in the internal table will be replaced with the above value.
Now it will be downloaded as required.
Regards,
Nishant Malhotra
Maybe you are looking for
-
Hard Drives locked after Leopard Install
Since this only happened after I installed Leopard, I figured here would be a good place. My apologies if it is not. The root ( /Volumes/Entreri/ and /Volumes/Akira ) are now read only. All folders and files within them have correct permissions. Hist
-
DVI scan converter to DVI HD-TV?
I have a DVI based HD-TV that only has 1080i/480p and is 30". My problem when I hook it up via DVI directly to my Mac, is that there is always both a horizontal and vertical overscan. What's the cheapest scan converter that offers pixel by pixel adju
-
When I encode video to a WMV file (bitrate 1500/3000) in Adobe Encoder CS6, the first fifteen to thirty seconds of video appears muddy and then corrects itself. When looking at it on the Premiere timeline it looks fine throughout. Any ideas on what c
-
How to check trunk port on 3548 xl switch
Hi all, i have 3548 xl switch i know on other switches i can use command sh int trunk but on this switch it does not work. do anyone knows which command we can use to check trunk ports other then this sh int fa switchport??????????? thanks mahesh
-
Animation works in browser preview, muse browser preview but not when live in Chrome!
I have an Edge animation that worked fine in Chrome, Safari and IE. The last time I published my Muse site (To BC) again (since update to CC2014) it no longer worked in Chrome! Preview in browser (Chrome) from edge works, preview in browser (Chrome)