473,320 Members | 1,946 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,320 software developers and data experts.

preserving format

I'm writing a wee utility that applies some simple transforms (eg adds
offsets) to some (text file) fields that represent floating point numbers.
Simple enough. However I would like to preserve the input format, e.g. if
the input looks like %15.7e then so should the output. Is there any
cunning use of e.g. sscanf to get not just the number, but also the
format?
TIA
Duncan

Feb 1 '07 #1
1 1184

On Thu, 1 Feb 2007, Duncan Muirhead wrote:
>
I'm writing a wee utility that applies some simple transforms (eg adds
offsets) to some (text file) fields that represent floating point numbers.
Simple enough. However I would like to preserve the input format, e.g. if
the input looks like %15.7e then so should the output. Is there any
cunning use of e.g. sscanf to get not just the number, but also the
format?
No, I don't think so. The best solution is probably just to parse the
numeric fields yourself, using 'isdigit' and 'strchr' and so on. Then
you can extract all the formatting information you need, and
simultaneously avoid undefined or unwanted behavior when the user starts
entering "numbers" like "+35798735738539757.2b".

If you don't want to actually compute the floating-point value yourself
(by successively adding multiples of powers of ten), you could also
parse the field yourself to start with, and then pass the original string
to 'sscanf' to compute the actual floating-point value.

-Arthur
Feb 3 '07 #2

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

Similar topics

1
by: JJ | last post by:
Hi, usually, I'm not using MS servers, but I have a big problem with a Access table. I should create a web application for a Historical Dipartment. They have create a populated a Access...
6
by: Karl | last post by:
This might not really be a javascript question, but I'll start with this group. At http://www.gazingus.org/ there is a very nice collapsible menu written using CSS and Javascript >>>> Using...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
2
by: Pete | last post by:
Hi all... I sincerly hope one of the MS guys can clear this up for me... First some background... Ok, I have a web site which is fully translatable into several languages. All the strings...
8
by: TheDude5B | last post by:
Hi, I have some data which is stored in my MySQL database as TEXT. when the data is entered in, it has some carriage returns in it, and this can be seen when querying the data using MySQL Query...
3
by: anju07 | last post by:
hi, Im using tabs in my jsp form, so, after i add the form details in tab1 of the form and save it, i want the details to be visible in the fields though in a read-only format. But, after saving the...
2
by: Clive Green | last post by:
Hello peeps, I am using PHP 5.2.2 together with MP3_Id (a PEAR module for reading and writing MP3 tags). I have been using PHP on the command line (Mac OS X Unix shell, to be precise), and am...
3
by: sophia.agnes | last post by:
Dear all, I was going through the book "C a software engineering approach by darnell & Margolis" there was a section named sign preserving vs value preserving it is as follows sign...
5
by: raaman rai | last post by:
if we are to have news management system in php for our site, how can we preserve the format of the contents. I mean a news can be long enough to have many paragraphs, and sometimes we may need to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
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
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.