I've looked around this forum, and the rest of the internet, but my code is not working. Here is the problem: I read XML files that are in en-US culture. The decimal separator is a dot ".". Given the string "123.45", I want to convert the separator from a dot, to a comma. The current code doesn't work. [CODE] String tmp = "123.45"; System.Globalization.CultureInfo myInfo = System.Globalization.CultureInfo.CurrentUICulture; /****The above line returns my culture, es-ES where the number separator is ","***/ System.Windows.Forms.MessageBox.Show("New value: "+ Decimal.Parse(test, myInfo)); /***The above line displays the result "12345"***/ [/CODE] I have a lot of variables to … | +0 forum 5 | ||
` //Header file: stackADT.h #ifndef H_StackADT #define H_StackADT //************************************************************* // Author: D.S. Malik // // This class specifies the basic operations on a stack. //************************************************************* template <class Type> class stackADT { public: virtual void initializeStack() = 0; //Method to initialize the stack to an empty state. //Postcondition: Stack is empty. virtual bool isEmptyStack() const = 0; //Function to determine whether the stack is empty. //Postcondition: Returns true if the stack is empty, // otherwise returns false. virtual bool isFullStack() const = 0; //Function to determine whether the stack is full. //Postcondition: Returns true if the stack is full, // otherwise … | +0 forum 4 | ||
Write a program in object code that will convert a 3-bit binary number to a decimal number,For example, if input is 101, output should be 5; if input is 011, output should be 3. that is what I have to do,this is what I have so far but its not working, Can someone point out what is wrong or what need to be changed 49 00 30 D1 00 30 1C F1 00 33 51 00 33 zz | +0 forum 4 | ||
I'm having problems with this program. Everytime i enter a fractional decimal number, it displays -0.0000 or sometimes garbage values. Ex: Enter any fractional decimal number: 5.7 -2.888blah blah blah garbage another Ex: Enter any fractional decimal number: 25.7 -0.000000 #include<stdio.h> int main(){ long double fraDecimal,fraBinary,bFractional = 0.0,dFractional,fraFactor=0.1; long int dIntegral,bIntegral=0; long int intFactor=1,remainder,temp,i; clrscr(); printf("Enter any fractional decimal number: "); scanf("%Lf",&fraDecimal); dIntegral = fraDecimal; dFractional = fraDecimal - dIntegral; while(dIntegral!=0){ remainder=dIntegral%2; bIntegral=bIntegral+remainder*intFactor; dIntegral=dIntegral/2; intFactor=intFactor*10; } for(i=1;i<=6;i++){ dFractional = dFractional * 2; temp = dFractional; bFractional = bFractional + fraFactor* temp; if(temp ==1) dFractional = dFractional - temp; fraFactor=fraFactor/10; } … | +0 forum 7 | ||
Hi Guys, If you have a Text Box which you are putting in the Decimal Places such as "15.50". Then Submitting this to a Access Database then on re-fresh the data shows in the grid view as "15.5". Where abouts should this be modified so that it shows Decimal Places? Is it on the Access DB Layout and how it's store or should there be come amendment on the code side? It looks like the GridView is removing the trailing '.00's' ?? Many thanks for any help. | +0 forum 11 | ||
Hi Guys, Hope you can help. (Bit of a N00b still).. I've written an Functioning Program (Good start!) However, I was wondering if there is a way for the data that is being shown currently in the Grid view to be shown with 'Decimal Places? The Data is Being pulled in via ODBC from a Access DB. The Table Column has been setup as 'DataType' = Currency with Decimal Places Defaulted to '1'. When looking at the data in the DB the Decimal Places are in the correct place but when pulling the data via ODBC into the GridView it … | +0 forum 5 | ||
I want to know how a microprocessor converts the binary digits into decimal equivalent. The processor only has the ability of manipulating 0's and 1's but, how these numbers are converted back into their decimal equivalent? Are they converted by another circuit? If so, then how and what it is called? Or If they are converted by the software? | +0 forum 2 | ||
I want to convert some numbers to binary, octal, and hexadecimal.. for example: . DECIMAL......BINARY......OCTAL.....HEXADECIMAL ................................................................... 1.................00000001.....001.......1 2.................00000010.....002.......2 And so on.. | +0 forum 1 | ||
How to give user the ability to set the decimal format rounding to whichever s/he prefers. I know that the users input can be gained by the code double decimalRoundTo; Scanner input = new Scanner(System.in); out.print(" Enter the number of decimal places you want to round to "); decimalRoundTo = input.nextDouble(); and the programmer can set the decimal format with the code below. out.format("%.2f", numberToBeRounded); However, I want to give my user that ability. How would this be possible, if it is at all? | +0 forum 4 | ||
Hello ! I have a script, that i m running on visual C++ compiler everything is alright with it, working properly but in the result, I can see on one digit after decimal, not 2, i wanna display two digit i.e 31.02 ; Code is; # include <iostream.h> # include <string.h> # include <math.h> # include <conio.h> # include <stdlib.h> //using std::string; int main() { char Continue; do { system("cls"); float hval,istval,isp,ival,gtot; int a=1; float isTotval=0.00; cout<<"How many sales items do you have? : "; cin>>hval; for (int i=0;i<hval;i++) { cout<<"Enter in the value of sale item "<<a<<" : $"; … | +0 forum 9 | ||
Write a complete, well-written, documented program (named convert) that prompts for and reads in a number with at most MAX_DIGITS (9) in one of the following four formats: binary, octal, decimal, and hexadecimal and converts it to a requested base. Once the number has been read in, you should verify that the number is valid (more on this later). If it is not valid, you should print the appropriate error message described below and exit with the specified error code immediately. After you determine the input is valid, you should determine what format the number is in (based on the … | +0 forum 5 | ||
How do you convert a decimal to binary and vice versa? using netbeans ide | +0 forum 5 | ||
Write a program in object code that will convert a 3-bit binary number to a decimal number,For example, if input is 101, output should be 5; if input is 011, output should be 3. that is what I have to do,this is what I have so far but its not working, Can someone point out what is wrong or what need to be changed 49 00 30 D1 00 30 1C F1 00 33 51 00 33 zz | +0 forum 3 | ||
So I am using spim and I am trying to figure out how to take a users input say "16" and then print it as 9 digit binary number. for example 16, 000010000 or say 4, 000000100, 67 01000011 etc etc always 9 spaces and in binary. I have all the input and I am currently just printing the number itself, but I want to print the binary anyone got any ideas/ tips? | +0 forum 2 | ||
how do you manually convert a multi digit ascii string into the hex equilavent of a decimal integer with out using a C library function. For instance If I have a small program asking a user to type into the keyboard a decimal number and lets say they type in 64357, and if this number is base 10 or decimal, the characters that get sent out a standard uart port would be the ascii equilavent of 0x36, 0x34, 0x33, 0x35, 0x37, on the receiving side of this uart, i would then need a 5 byte (unsigned char) array how do … | +0 forum 4 | ||
Hi, I was assigned by my teacher to create a simple calculation program about movie tickets that are sold in a local movie theater. So, I created the coding, and it turned out perfect. Here it is: import java.util.Scanner; public class MovieTheater { public static void main(String[] args) { String movieName; double adultPrice, childPrice, totalAdultPrice, totalChildPrice, grossAmount, percentageDonation, amountDonated, netSale; int adultNumber, childNumber, totalTickets; Scanner keyboard = new Scanner(System.in); System.out.println(" Enter the Movie Title: "); movieName = keyboard.nextLine(); System.out.println(" Adult ticket price per person: "); adultPrice = keyboard.nextDouble(); System.out.println(" Child ticket price per person: "); childPrice = keyboard.nextDouble(); System.out.println(" Number … | +0 forum 2 | ||
[COLOR="Green"][CODE]Private Sub Text1_Change() Text1 = Format(Text1, "#,###") Text1.SelStart = Len(Text1.Text) End Sub[/CODE] This code formats the textbox value to include a comma for every 3 digits to the left. Problem is, it doesn't allow to type decimals like 3,000,000.50 What can I do?[/COLOR] | +0 forum 17 | ||
My code works for numbers that dont have a remainder of 10 or above, but whenever I get one with a remainder 10 or above it prints out the number, not the letter. Please help #include <iostream> #include <fstream> using namespace std; const int maxstack = 51; class stack_type { public: void clear_stack(); bool empty_stack(); bool full_stack(); void push (int numb); void pop (int& numb); int stack[maxstack]; int top; }; void main() { stack_type remainder_stack; int n, number, remainder; char response; remainder_stack.clear_stack(); do { cout << "Enter positive integer to convert to base 16: \n\n"; cin >> number; n = … | +0 forum 2 | ||
hi. so i need help in understanding this program. its a hindu arabic - roman numeral converter. i got it from some site. i cant seem to understand how the whole process goes. Const sMatrix As String = "I~V~X~L~C~D~M" Private Function toroman(ByVal sDecNum As String) As String Text1.Text = sDecNum If sDecNum <> "0" And sDecNum <> vbNullString Then If Len(sDecNum) > 3 Then text2.Text = String(Mid(sDecNum, 1, Len(sDecNum) - 3), "M") If Len(sDecNum) > 2 Then text2.Text = text2.Text & GiveLetters(Mid(sDecNum, Len(sDecNum) - 2, 1), 4) If Len(sDecNum) > 1 Then text2.Text = text2.Text & GiveLetters(Mid(sDecNum, Len(sDecNum) - 1, … | +0 forum 5 | ||
Hi I have a script which displays a price but currently is not fixed to 2 decimal places so a price such as $2.50 shows as $2.5 which to me looks wrong. The line of code is `amount += parseFloat($(this).metadata().amount);` Looking around I see there is a function `toFixed()` but I am not sure how to combine it with the above. Any help much appreciated. Thanks Mark | +0 forum 3 | ||
Hi there, I'm having trouble with floats in Java. My program accepts a number in the form of a float. The number typically has two decimals (but not always). It seems to work fine in most cases. For example, I could put in 54.67, and that number would be passed to another function. Great. However, my problem is this: If I put in 54.60 as the number, it gets set as a float, which automatically rounds it to 54.6, and passes **that** to the other function. The other function doesn't work properly when this 0 is dropped. So my question … | +0 forum 4 | ||
Code Snippet
Binary to Decimal Conversion The computer is a binary beast. We want to go from the one-fingered digital box to the ten-fingered human being and convert binary to denary(base 10) numbers. This is how it works, for instance, binary 10010 is calculated as 1*16+0*8+0*4+1*2+0*1 = decimal 18. Just because it's easy, let's throw in hexadecimal and octal results too. The added bonus is the almost foolproof entry of data. | +0 forum 18 | ||
I intend to write a GUI java program which convert a decimal(base 10) to hexadecimal(base 16). Floating point decimals are also valid input. the code of my program private void myEnterButtonActionPerformed(java.awt.event.ActionEvent evt) { float mynum; mynum = Float.parseFloat(this.myNumberField.getText()); Float floatObject = Float.valueOf(mynum); myResultField.setText(Float.toHexString(mynum)); } but when I run the program, the input of 12.9 gives 0x1.9cccccp3, whereas I want the output as C.E6666 Help me to solve this problem. | +0 forum 13 | ||
Heres the thing. This was one our class test and the image below is the lecturers question that is supposed to be one of his jokes(Binary/base). A large amount of the class answered that it was decimal 10. Every ideas and thought would be appreciated. Heres the image [Click Here](http://imgur.com/OwEKO) | +0 forum 2 | ||
Help me please.. I can't make this code in window form application.. using System; namespace _01.Decimal_to_Binary { class DecimalToBinary { static void Main(string[] args) { Console.Write("Decimal: "); int decimalNumber = int.Parse(Console.ReadLine()); int remainder; string result = string.Empty; while (decimalNumber > 0) { remainder = decimalNumber % 2; decimalNumber /= 2; result = remainder.ToString() + result; } Console.WriteLine("Binary: {0}",result); } } } please help me.. thanks | +0 forum 4 | ||
just forgot, I knew this "Textbox1.text = format(textbox1.text, “####.00”)" will set up the format to 4number with two decimal - 1234.00, how about if the user enter 12345.00, five number with two decimal, how did you do the check and give error message? Thanks. | +0 forum 1 | ||
Hi Guys, I have written the below program to convert binary to octal, it is giving me erroneous results. On entering 1111 as the input number I should get 17 as the output, whereas I am getting 16707000337 as the output. Kindly help me out, below is my program: /*program to convert binary to octal*/ #include<math.h> #include<stdio.h> #include<stdlib.h> int main() { int bin,dec[100]={0},i=0,j=0,k=0,num=0,output[100]={0},number=0,rem1,rem,output1; printf("enter the binary number to be converted into octal"); scanf("%d",&bin); rem1=bin; /*counts the number of digits in the input binary number*/ while(rem1!=0) { rem1=rem1/10; num+=1; } /*converts binary number to decimal */ for(i=0;i<num;i++) { number=bin%10; bin=bin/10; dec[i]=pow(2,j)*number; … | +0 forum 2 | ||
Alright guys, I've been trying to think how to do this and I keep confusing myself. It's part of a project using piping in UNIX but first I need to get this small program running properly. I want to pass the final result (Hex value) to another program that will convert that result to binary. This is my current code, which runs fine, although I was thinking of storing the value where is says printf("A"); ,for example, into an array. Although, I need to pass the array to another program which is looking for an int value. I think the … | +0 forum 2 | ||
I am trying to get the program's decimal to output in two decimal places after the decimal. Please advise. [CODE] // MilesPerGallon.java // Program designed by XY import javax.swing.JOptionPane; // Needed for JOptionPane. import java.text.DecimalFormat; // Keeping proper decimal format. public class MilesPerGallon { public static void main(String args[]) { double miles_driven; // amount of miles driven double GallonsOfGas; // gallons of gas used String input; // hold user's input double MPG; // miles per gallon // Create a DecimalFormat object. DecimalFormat dec = new DecimalFormat("###.##"); // Get the number of miles driven from user. input = JOptionPane.showInputDialog("Enter the number … | +0 forum 3 | ||
Let me start off by saying that this is homework, and I have most of it completed. However, I am stuck on how to convert decimal to hexadecimal. The assignment is to add two hexadecimal numbers and output the answer. If the length of the answer is greater than 10 digits, then output "Addition Overflow." I've completed the conversion of the two strings to decimal and added them together, now I think that I need to convert the answer back to a string. I know it's long, but if you would take the time to read my code, then it … | +0 forum 42 |
The End.