473,382 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Serialization of Double gives a '1E-12' - I want 0.000000000001

Hey

I am running into this issue.

I have a Serializable Class that has a Double member.

I am using XmlSerializer to serilaize this object,
If the Double member is large (or very small) , the XmlSerializer is
converting this to its Scientific Notation (ie. 0.000000000001 -'1E-12')

I dont want '1E-12' but instead I want 0.000000000001

Any suggestions?

Thanks

Aug 29 '07 #1
2 2879
Nutshell wrote:
I have a Serializable Class that has a Double member.

I am using XmlSerializer to serilaize this object,
If the Double member is large (or very small) , the XmlSerializer is
converting this to its Scientific Notation (ie. 0.000000000001 -'1E-12')

I dont want '1E-12' but instead I want 0.000000000001
I'm not clear on why the representation of the number is important. The
two strings are equivalent. But if it is, you should be able to
implement ISerializable for your class to override the default behavior.
Then you can use whatever custom formatting you like to ensure that
the serialized data has the exact representation you want.

Pete
Aug 29 '07 #2
Thanks Peter -

The issue is that I do need the number representation.

And unfortunately , I have 100+ classes that I would need to implement an
ISerializable on -

you wouldnt happen to have a short example :)

"Peter Duniho" wrote:
Nutshell wrote:
I have a Serializable Class that has a Double member.

I am using XmlSerializer to serilaize this object,
If the Double member is large (or very small) , the XmlSerializer is
converting this to its Scientific Notation (ie. 0.000000000001 -'1E-12')

I dont want '1E-12' but instead I want 0.000000000001

I'm not clear on why the representation of the number is important. The
two strings are equivalent. But if it is, you should be able to
implement ISerializable for your class to override the default behavior.
Then you can use whatever custom formatting you like to ensure that
the serialized data has the exact representation you want.

Pete
Aug 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Julián Albo | last post by:
Hello. This test: #include <stdio.h> int main () { double a= -1.0e-120; if (a < 0.0)
29
by: Peter Ammon | last post by:
What's the most negative double value I can get? Is it always guaranteed to be -DBL_MAX? If so, why (or rather, where)? Thanks.
3
by: Hans Ginzel | last post by:
Hello, let us consider function int foo(char *name, void *data) { ... printf(name, data); /* Should be *data? */ ... }
22
by: bq | last post by:
Hello, Two questions related to floating point support: What C compilers for the wintel (MS Windows + x86) platform are C99 compliant as far as <math.h> and <tgmath.h> are concerned? What...
1
by: bsmith1111 | last post by:
I have a program that outputs the following to the screen (through visual c++) 9999999999, which is stored in a double. I would like to keep the number the way it is, but every time I output it...
8
by: Camellia | last post by:
Just a humble question, I tried to assign a real number with exponents to a variable but obviously I can't do: double a = 1e-10; The compiler will in turn complain about the undefined 'e'. So,...
17
by: Thomas Kowalski | last post by:
Hi, I would like to know whether someone knows a library or function that parses a string containing 3 double numbers in the form like xxxx.yyyyyyyyy xxxx.yyyyyyyyy xxxx.yyyyyyyyy really fast....
18
by: brekehan | last post by:
I ran across some code that is initializing a double: double x = 1e-5; Does the standard dictate the compiler to interpret that as 0.00001? or is the above representation error prone? ,...
206
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
10
by: ratcharit | last post by:
Currently using cosine function in math.h Currently I get: 1 = cos(1e^-7) Is there another way for cos to return value of high accuracy say: 0.999999 = cos(1e^-7)
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.