473,657 Members | 2,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

storing java float/double as a string

14 New Member
I want to store a float/double as String. I have an input file with a column with float values i.e. have the form 1.4E15. I want to store these values as Strings. Here is my code which is resulting in storing 1.4E15 not the value as a String.

Expand|Select|Wrap|Line Numbers
  1.  
  2. String accNumber="";//declaring and initialisation
  3.  
  4. //open file and read line then store the column in accNumber
  5. //the line read has been stored into an array String split[]
  6.  
  7. accNumber=split[2].trim();
  8.  
  9. //how do I make sure it does not store 1.4E15
Oct 7 '07 #1
1 2647
dmjpro
2,476 Top Contributor
I want to store a float/double as String. I have an input file with a column with float values i.e. have the form 1.4E15. I want to store these values as Strings. Here is my code which is resulting in storing 1.4E15 not the value as a String.

Expand|Select|Wrap|Line Numbers
  1.  
  2. String accNumber="";//declaring and initialisation
  3.  
  4. //open file and read line then store the column in accNumber
  5. //the line read has been stored into an array String split[]
  6.  
  7. accNumber=split[2].trim();
  8.  
  9. //how do I make sure it does not store 1.4E15

Look at this Code.

Expand|Select|Wrap|Line Numbers
  1. double d = 1.4E15;
  2. BigDecimal bd = new BigDecimal(d);
  3. System.out.println(bd.toPlainString());
  4.  
Debasis Jana
Oct 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2852
by: SCOTT DELIBAC | last post by:
Can Anyone Help?? I have this program which is listed below. I want to take the grades that the students have assigned to them, and assign the letter grades a numeric value so that I can calculate their GPA. I just have no idea how I am supposed to do that?? Can anyone HELP!!! import javax.swing.*; import java.util.*; public class GradePoint { public static void main(String args) {
30
10929
by: Richard | last post by:
Level: Java newbie, C experienced Platform: Linux and Win32, Intel Another programmer and I are working on a small project together. He's writing a server process in Java that accepts input from processes I've written over a TCP connection. My processes are all written in C; his are all done in Java. He's new to Java, and I've never really used it. My input is basically a stream of 32-bit unsigned integers (e.g., the
6
7606
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards, Karthi
1
1684
by: glen stark | last post by:
Hi everyone. I would like to consider the following problem: I want to provide the ability to store and manipulate numeric container classes that provide 1) element wise access 2) size but maybe not with the same interface. For example MatrixType1 provides element access, and size1() and size2() for size access. MatrixType2 provide (i,j) element access. Now, these matrix classes might contain doubles, floats, integers,
6
2911
by: Steve | last post by:
Hi, I've developed a testing application that stores formatted results in a database. Recently it was requested that I add the ability to generate graphs from the raw, un formatted test results (100,000+ float values) I don't intend to store all of the 100,000 datapoints, but rather a subset of say 250. Due to the volume of testing that we need and the volume of results stored, I need to be VERY careful with data size and keep things...
6
5431
by: aureao4 | last post by:
I'm new to Java and programming. I'm trying to code a payroll program and continue getting errors. The program worked last week, this week I have to add set, get and a class. I've written the class but when I compile the program I get 13 errors. Can anyone assist me with this? Thank you! Errors I get: C:\Java>javac *.java Payroll3.java:18: illegal start of type while ( !exit ) ^ Payroll3.java:18: <identifier>...
5
6275
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is JDK 6 downloadable from http://java.sun.com/javase/downloads/index.jsp. I will be using JDK 5(update 8)
2
2520
by: pinkf24 | last post by:
I cannot figure out how to add the following: Modify the Inventory Program to include an Add button, a Delete button, and a Modify button on the GUI. These buttons should allow the user to perform the corresponding actions on the item name, the number of units in stock, and the price of each unit. An item added to the inventory should have an item number one more than the previous last item. Add a Save button to the GUI that saves the...
3
2572
by: gator6688 | last post by:
import java.text.DecimalFormat; import javax.swing.JOptionPane; public class PayrollSystemTest { public static void main( String args ) { String workerType; String first; String last;
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.