HELP! Converting ascii to its decimal codes
Does anyone know how to convert ascii code to its decimal equivalent? Is there a simple function that can do this?
Thanks for any help!!
Yes there is.
String whatever = "whatever"
char[] chars = whatever.toCharArray();
for(int i=0; i<chars.length; i++) {
System.out.println( (int) chars[i] );
And since its friday I wont flame you for not reading
a simple tutorial, though its hard not to
ehmm, the square brackets around the chars[i] are replaced by
non-squares, or not visible, but they ARE square brackets
Similar Messages
-
Help converting binary to decimal.
Hi all.
I'm taking a course in Java programming and so far its been a great experience. I'm currently stumped on one of my assignments and I am kindly requesting some assistance.
Basically I have to convert a binary entry into its decimal comparison.
so for instance an entry of 1101 would output 13.
I have the calculation formula, but my problem is finding out whether the point i'm looking at is either a 1 or a 0. I can't seem to 'strip it down' to the value.
My current thought is something like this:
binary = 1101;
// problem is here
thou = (binary % 1000) / 1000;
hund = (thou % 100) / 100;
tens = (hund % 10) / 10;
ones = (tens % 1) / 1;
// then do formular
decimal = ones * 1 + tens * 2 + hund * 4 + thou * 8;
I have searched but all the suggestions say to use a custom function or other obscure method. I don't know that stuff real well and we aren't even that far in the book either. All we've done so far is while, if .. else, condition statements.
I will include the actual text for the question, in case i'm not clear. This text also includes a 'tip' which isn't helping me. (http://www.geocities.com/kaveman2000/q-4-25.pdf)
Thanks again for any pointers.angeles1016 (and all),
thanks for your great help and code snippets.
angeles1016,
using the code you provided i noticed that the last (single digit) was giving the wrong response in certain cases. (1000, 0111, 0001, ..) i could be off one.
either way, i decided to fix it up and give you all the update.
// do class, main function stuff
if(binary/1000 == 1){
thousands += (binary/1000);
temp = binary % 1000;
if(temp/100 == 1){
hundreds += (temp/100);
temp = temp % 100;
if(temp/10 == 1){
tens += (temp/10);
temp = temp % 10;
if(temp/1 == 1){
ones += (temp/1);
// calculate binary to decimal
decimal = (ones * 1) + (tens * 2) + (hundreds * 4) + (thousands * 8);
// take result and convert to string for output
result += "Decimal: " + decimal + "\n";
// display in gui ?
// end function and class stuff(note: i suppose the statements similar to "thousands += (binary/1000);" can be simplified as "thousands = 1;") -
cannot activate my viber after i update to 6.1.3 iphone 3gs..can u please help me...the the code is ok but if i activate...its being error.
@theViberTeam .
I'm having trouble with Viber.
A few days ago, I accidentally uninstalled it on my IPhone 4, and reinstalled it later on..
When I tried sending the activation code using the same cell phone number I had on Viber before It got uninstalled, I receive the code but when I try to put it in it keeps saying that I entered the wrong activation code, I click on the no code feature on the top right corner of Viber, it gives me a code, but when I put that code in it says the same thing ,that I have the wrong access code please try again, and so I researched on the internet and came up to this post, It said to uninstall viber and wait 24 hours to install it again, I waited 24hours and tried it again, but it STILL does the same thing. and... I even tried entering my other phone number, yet it does the same thing and shows me the same message that I entered the wrong access code....It is getting frustrating! May you please Help ME?! What can I do?? -
Convert IPv6 address to decimal
How do we convert an IPv6 address to its decimal equivalent using java?
I could find different tools on Internet but not the java code for the same.
Any help would be much appreciated.
Thanks.Hello EJP
Please visit the following URL:
https://www.ultratools.com/tools/decimalCalcResult?ipAddress=805b%3A2d9d%3Adc28%3A0000%3A0000%3Afc57%3Ad4c8%3A1fff
This converts the IPv6 address (which is in hexadecimal format) to a decimal number.
I need to implement this functionality. I could not find any method in java.net.Inet6Address class for this.
To convert an IPv4 address which is in String format to its decimal equivalent, we can use following method:
<code>
long stringToLong(String ipAddress) {
String[] octets = ipAddress.split("\\.");
long intValue = 0;
long currentOctet;
for (int i = 0; i < octets.length; i++) {
currentOctet = new Integer(octets[(octets.length-1)-i]).intValue();
intValue = (currentOctet << i*8) | intValue;
return intValue;
</code>
Edited by: 803674 on May 26, 2011 12:22 AM -
Convert hexadecimal output to decimal (number)
I am reading hexadecimal format from the output of the VISA read block and I want to convert it to the decimal preferably exponential format.
Example of what I read is 76 00 02 (in dec: 7.600 E+2).
I know there is "type cast" block that converts nicelly but I am not sure what to specify for a type input.
Can you show me how to apply this type cast block for in my VI so that it converts hex string (76 00 02) into exponential string/number (7.600 E+2)?
I attached my VI so it is more clear.
Thanks everybody,
Pedja
Attachments:
MultiGauge.vi 64 KBCoop wrote:
> I am reading hexadecimal format from the output of the VISA read block
> and I want to convert it to the decimal preferably exponential format.
> Example of what I read is 76 00 02 (in dec: 7.600 E+2).
> I know there is "type cast" block that converts nicelly but I am not
> sure what to specify for a type input.
> Can you show me how to apply this type cast block for in my VI so that
> it converts hex string (76 00 02) into exponential string/number
> (7.600 E+2)?
Looking at your code I see that you have not a hexadecimal string coming
back but instead a binary string. The fact that you display the string
as hexadecimal in the string indicator is just showing you the ASCII
codes of the string characters as hexadecimal numbers.
The funct
ion From Hexadecimal String expects a clear text string with
hexadecimal characters but that is something entirely different from a
binary string you choose to display as hexadecimal numbers.
An example: the binary string 7600 02 you receive from the device is in
fact the character 'v', a null character and a 02 character (or in ASCII
terms a start of text character).
So assuming your example is right (which I have to admit seems very
strange and therefore suspicious to me) you would have to do something
more like included example. But as I said I have little understanding
why the hexadecimal interpretation of the binary values should
correspond to the decimal value you want to have!
Also as you can see there is not really clear where the 00 character
belongs to. The two methods where it is either part of the multiplier or
the exponent both produce the same result for this particular example.
Which one is right if any, should be tested.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions
Attachments:
Binary_(Hex)_to_Decimal_Numeric.vi 51 KB -
How could I choose some bytes from HEX string and then convert it to a decimal value?
Hi I am working with an OMRON E5EN temperature controller using VISA serial to get data, I send the Read from Variable Area command and get this string in hexa 0230 3130 3030 3030 3130 3130 3030 3030 3030 3030 3041 3203 71 or .01000001010000000000A2.q in ASCII this string means:
02 STX
3031 3030 Node and subadress
3030 End Code Normal Completion
3031 3031 Command Read from Variable Area
3030 3030 respt code Normal completion
3030 3030 3030 4132 Hexadecimal A2 = 162 (this is the temperature data that I want to show in decimal)
03 ETX
71 Block Check Character
I want to choose the eight bytes for the temperature data and convert it to a decimal number. I have seen the examples to convert a Hexa string to decimal but I do not know how to choose the specifics bytes that I need.
I have look for a driver but i didn´t find any. I am a beginner so please include especific topics for me to study in your answer.
Thanks
Carlos Fuentes Silva Queretaro MexicoIf the response always has the temperature starting with byte 15 and is always 8 bytes in length, you can use the String Subset function to get those bytes out of the string. Then use Hex String to Number to convert to a decimal number.
Well someone already beat me to the solution:
Message Edited by tbob on 01-04-2008 04:42 PM
- tbob
Inventor of the WORM Global
Attachments:
HexStr2Decimal.png 7 KB -
Hello I need some help.
I need to convert the ASCII data to Binary form. Like if i have the character 'A' and its ASCII is 65 then its binary would be 01000001.
If there is any function/method available in java to convert ascii to binary, i would be really thanful.Hello I need some help.
I need to convert the ASCII data to Binary form. Like
if i have the character 'A' and its ASCII is 65 then
its binary would be 01000001.
If there is any function/method available in java to
convert ascii to binary, i would be really thanful.
byte ascii = 65;
String binresult = "";
for(int i=0;i<8;i++) {
if(ascii%(2^i)=0) binresult += "0";
else binresult += "1";
} -
Hi All,
I have a requirement to convert ASCII files (formatted files when opened through Textpad / Editplus) into HTML when its hyperlink is clicked from my application.
The present code is that, the TXT file was streamed, html tags have been added and the entire file was re-written as HTML (based on char 12 / 32, as the case may be) and saved as JSP / HTML extension, and placed in a temp folder.
response.sendRedirect() was used to open this file, which threw OutofMemoryException errors.
It was also revealed that, if the original ASCII file was 40KB, the converted JSP file would be 160KB (around 4 times)
The ideal conversion should be - add html tags in the new file and maintain the same formatting as the original ASCII file, & save the file with new extension.
Thus I need a memory efficient method such that these files are converted on the fly by the application, yet the size kept minimum.
Please suggest. Thanks in advance
Regards
Hari N160k is trival on a modern desktop OS. Especially since it is temporary. What heap size is the server using?
-
How to convert ascii to character
how to convert ascii to character is there any function module or any code.plz help me in finding this.
Hi,
please go through this
If I give input as 65 (ascill value) I want display 'A'.
Below logic is for convert from character to ascii value.
report Ascii_convert.
*Going from A to 65
data : c value 'A'.
field-symbols : <n> type x.
data : rn type i.
assign c to <n> casting.
move <n> to rn.
write rn.
*Going from 66 to B
data : i type i value 66.
data : x type x.
field-symbols : <fc> type c.
move i to x.
assign x to <fc> casting type c.
move <fc> to c.
write c.
i hope this will help you ,
Raja T -
Converting ascii to iCal?
I currently use Solaris CDE with Calendar details kept
in ascii format. If I am going to use iPlanet's latest
version of Calendar I need a way of importing all of ascii files for users into iCal. Otherwise I'm left resubmitting all details for the year.Hello I need some help.
I need to convert the ASCII data to Binary form. Like
if i have the character 'A' and its ASCII is 65 then
its binary would be 01000001.
If there is any function/method available in java to
convert ascii to binary, i would be really thanful.
byte ascii = 65;
String binresult = "";
for(int i=0;i<8;i++) {
if(ascii%(2^i)=0) binresult += "0";
else binresult += "1";
} -
Convert a String to Decimal Format in European format
Hi Experts,
I am having a string as a context type for a input field, where the user can enter the Price, I need to convert the same into European format "###.###,00", I am using this below code to convert the string to decimal format
User will enter the input as 10 as it needs to be converted into 10,00. Also, 1000 which has to be converted as 1.000,00
String Str1 = wdContext.currentvn_temptable.getVa_TempUnitPrice();
Locale mylocale = Locale.GERMAN;
String pattern="###.###,00";
NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern(pattern);
String output = df.format(Str1);
wdComponentAPI.getMessageManager().reportSuccess("Unit Price" + " " + pattern + " " + output);
When I execute the above code, i am getting an error called "Malformed Pattern ###.###,00"
Please let me know, how to convert a String to Quantity in European format
Thanks & Regards,
PalaniHello!
Try to change your pattern to this one
Locale mylocale = Locale.GERMAN;
String pattern = "#,#00.00";
NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern(pattern);
String output = df.format(1111111.222);
Pattern has an influence on number of digits between separators, but you have to use ',' for grouping and '.' for decimal. Character values for separators correspond to your Locale object.
Thanks, Mikhail -
Exception --- Value can not be converted to requested type.Error Code: 0
Inside my query, I try to use function,like
Expression formattedRegDateCol = regDateCol.getFunction("to_char", "YYYY/MM/DD");
sometimes query works fine and sometimes got following exception, can anyone here help me out..
Internal Exception: java.sql.SQLException: [BEA][Oracle JDBC Driver]Value can not be converted to requested type.Error Code: 0
Call:SELECT COUNT(*), to_char(REG_DATE, 'YYYY/MM/DD') FROM SYSTEM_DETAIL WHERE ((REG_DATE BETWEEN {ts '2008-08-10 00:00:00.0'} AND {ts '2008-09-30 23:59:59.0'}) AND (GEOGRAPHIC_ID = 104)) GROUP BY to_char(REG_DATE, 'YYYY/MM/DD') ORDER BY to_char(REG_DATE, 'YYYY/MM/DD') ASC
Query:ReportQuery(com.cad.registration.RegistrationDetailImpl)
at com.cad.report.data.DocumentReturnedDataGenImpl.loadData(DocumentReturnedDataGenImpl.java:130)
at com.cad.report.data.AbstractDataGen.getReport(AbstractDataGen.java:96)
at com.cad.report.command.ProcessReportRequestOnMessage.run(ProcessReportRequestOnMessage.java:74)
at com.cad.registration.command.AbstractCommand.execute(AbstractCommand.java:106)
at com.cad.flow.core.Run.run(Unknown Source)
at com.cad.flow.core.WorkflowComponent.run(Unknown Source)
at com.cad.flow.ejbs.WorkflowManagerBean.execute(WorkflowManagerBean.java:238)
at com.cad.flow.ejbs.WorkflowManagerBean.execute(WorkflowManagerBean.java:135)
at com.cad.flow.ejbs.WorkflowManager_uh667k_EOImpl.execute(WorkflowManager_uh667k_EOImpl.java:132)
at com.cad.flow.ejbs.WorkflowManager_uh667k_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:335)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:252)
at com.cad.flow.ejbs.WorkflowManager_uh667k_EOImpl_1001_WLStub.execute(Unknown Source)
at com.cad.util.WorkflowProxy.runWorkflow(WorkflowProxy.java:128)
at com.cad.kbd.messenger.listener.mdb.ReportRequestMDB.onMessage(ReportRequestMDB.java:84)
at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4072)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:3964)
at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4490)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
Caused by: Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070620)): oracle.toplink.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: [BEA][Oracle JDBC Driver]Value can not be converted to requested type.Error Code: 0
Call:SELECT COUNT(*), to_char(REG_DATE, 'YYYY/MM/DD') FROM SYSTEM_DETAIL WHERE ((REG_DATE BETWEEN {ts '2008-08-10 00:00:00.0'} AND {ts '2008-09-30 23:59:59.0'}) AND (GEOGRAPHIC_ID = 104)) GROUP BY to_char(REG_DATE, 'YYYY/MM/DD') ORDER BY to_char(REG_DATE, 'YYYY/MM/DD') ASC
Query:ReportQuery(com.cad.registration.RegistrationDetailImpl)
at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:282)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.getObject(DatabaseAccessor.java:988)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.fetchRow(DatabaseAccessor.java:780)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:562)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:441)
at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:457)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:117)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:103)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:174)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:481)
at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:825)
at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectAllReportQueryRows(ExpressionQueryMechanism.java:791)
at oracle.toplink.queryframework.ReportQuery.executeDatabaseQuery(ReportQuery.java:518)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:620)
at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:779)
at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:451)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:2089)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:965)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:878)
at com.cad.persistence.toplink.TopLinkPersistenceBrokerImpl.executeQuery(TopLinkPersistenceBrokerImpl.java:420)
at com.cad.report.data.DocumentSys.getSummitedDocumentNumber(DocumentSys.java:332)
at com.cad.report.data.DocumentSys.loadData(DocumentSys.java:110)
... 24 more
Caused by: java.sql.SQLException: [BEA][Oracle JDBC Driver]Value can not be converted to requested type.
at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
at weblogic.jdbc.base.BaseData.getTimestamp(Unknown Source)
at weblogic.jdbc.base.BaseResultSet.getTimestamp(Unknown Source)
at weblogic.jdbc.wrapper.ResultSet_weblogic_jdbc_base_BaseResultSet.getTimestamp(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.getObjectThroughOptimizedDataConversion(DatabaseAccessor.java:1038)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.getObject(DatabaseAccessor.java:942)
... 45 moreHere is my code
ExpressionBuilder builder = new ExpressionBuilder();
ReportQuery query = new ReportQuery(RegistrationDetailImpl.class, builder);
query.addArgument("startTime");
query.addArgument("endTime");
query.addArgument("lro");
Expression lroCol = builder.get("lro");
Expression regDateCol = builder.get(
QueryConstants.RegistrationDetailQueryConstants.REGISTRATION_NUMBER_COL).get(
QueryConstants.RegistrationDetailQueryConstants.REGISTRATION_DATE_COL);
Expression formattedRegDateCol = regDateCol.getFunction("to_char", "YYYY/MM/DD");
Expression timeExp = regDateCol.between(builder.getParameter("startTime"), builder
.getParameter("endTime"));
Expression lroExp = lroCol.equal(builder.getParameter("lro"));
query.setSelectionCriteria(timeExp.and(lroExp));
query.addCount();
query.addAttribute("regDate", formattedRegDateCol);
query.addGrouping(formattedRegDateCol);
query.addOrdering(formattedRegDateCol.ascending());
descriptor.getDescriptorQueryManager().addQuery("testquery", query); -
Download helper converts to .flv instead of .avi
since a few months when downloading a video from the same source, the download helper converts to .flv and no longer to.avi.
what do I need to do to have .avi?
Even if it downloads as .avi, it converts automatically to .flv .
Thank you for help.
Rgds piaThe first thing that you need to consider is whether or not
this project
will work well on the web. If you have to make a bunch of
compromises to
get it working on the web, then it may not represent you
well.
That said, you can use FLVs in Director MX 2004 with the
latest updates.
However, you can't stream the FLVs, you have to encapsulate
each one in
an SWF and then use the SWF. So if its the streaming that
you're after,
you may want to use QT instead. You can stream that.
Regardless of the video media that you use, you need to be
sure that you
aren't taking a smooth CD based experience and turning it
into a click
and wait, click and wait, less than elegant web experience.
If you want
to showcase your video capabilities then you may want to
build a web
specific tool. Or, you may want to let site visitors request
a CD to be
mailed to them.
Rob
Rob Dillon
Adobe Community Expert
http://www.ddg-designs.com
412-243-9119
http://www.macromedia.com/software/trial/ -
How to convert a BCD to Decimal?
Hi,
I am using a LabVIEW code for Interfacing a channel selection box.In that output am getting is in the format of BCD.I want to convert that BCD to decimal.Can you Plz tell me to convert this BCD to Decimal?
Please Mark the solution as accepted if your problem is solved and donate kudoes
Solved!
Go to Solution.You can use the Boolean operators and the Rotate function to select the hi and low nibbles. Use the In Range and coerce function to limit the range of the nibbles to zero through nine.
Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.
"You are what you don't automate"
Inplaceness is synonymous with insidiousness
Attachments:
U8 to BCD Hi and Low.PNG 20 KB
U8 to BCD Hi and Low.vi 7 KB -
I am trying to Convert some music videos to play on my iPod but when I click "convert Selection for iPod" iTunes will shut down. Also if I try to convert them in QuickTime it does the samething and shuts Quick Time down. I have reinstalled iTunes and Quick Time and also updated Windows with all the latest updates but still no luck. Any ideas what to try now? Thanks for any help.
Hi Linda, While its good to have Quicktime Pro in your arsenal of video eiting tools, it has it's limitations. May I suggest going here and down loading the trial of this software. The software will convert most file types except Real media (RM) files. It is also available for download purchase or in one of the stores listed.
http://www.divmm.com/
Maybe you are looking for
-
My iPod touch is switching songs while in it is playing and the voice control is also causing the music to stop at times. Help!
-
IPOD VIDEO 30GB not recognized by iTunes or My PC
So I have this ipod that I'm trying to revive. I'm not even sure which generation it is, but it's a 30GB ipod classic and I bought like in 2005. Here's the thing, this ipod has been in my drawer for years and when I turn it on it says "Use itunes to
-
PDFMaker missing files issue with PDF Forms from Office 2007
Hi, I have Adobe PDF 8.0 Pro installed (full installation) and I upgraded office from 2003 to 2007 AND Windows from 2000 to XP Pro. I used to be able to create PDF Forms from an Excel document when using Office 2003. Now, when I choose to create a n
-
ScriptMenuAction Label not assigned in CS3 JS
The below script is working fine in CS4 but in CS3, the label is not assigned properly. var myScriptAction = app.scriptMenuActions.add("TestingMenu"); myScriptAction.label="Automation"; alert(myScriptAction.label); My requirement is, i want to know m
-
how to clean hard drive