473,394 Members | 2,160 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,394 software developers and data experts.

splitting a long token across lines

Hi all,

Say, I have a very long integer constant , how can
I split across lines ?
I tried something like
MODULUS = 7567567567567567567567567567567\
7567507546546986094860986094860\
2345646986598695869548498698989\
...
but it doesn't compile.
Is there another way to write a long numeric constant besides writing
it as a string and then converting to long? I also wouldn't like to put
it all on one very long line.

Thanks!
Jul 18 '05 #1
4 1374
why can't you just write it like this:

MODULUS = A*pow(10,a) + \
B*pow(10,b) + \
C

"Nakamura" <la******@yahoo.com> wrote in message
news:ef**************************@posting.google.c om...
| Hi all,
|
| Say, I have a very long integer constant , how can
| I split across lines ?
| I tried something like
| MODULUS = 7567567567567567567567567567567\
| 7567507546546986094860986094860\
| 2345646986598695869548498698989\
| ...
| but it doesn't compile.
| Is there another way to write a long numeric constant besides writing
| it as a string and then converting to long? I also wouldn't like to put
| it all on one very long line.
|
| Thanks!
Jul 18 '05 #2
djw
Nakamura wrote:
Hi all,

Say, I have a very long integer constant , how can
I split across lines ?
I tried something like
MODULUS = 7567567567567567567567567567567\
7567507546546986094860986094860\
2345646986598695869548498698989\
...
but it doesn't compile.
Is there another way to write a long numeric constant besides writing
it as a string and then converting to long? I also wouldn't like to put
it all on one very long line.

Thanks!


Well, I _suppose_ you could do this:
MODULUS = "7567567567567567567567567567567"\
7567507546546986094860986094860"\
2345646986598695869548498698989"\
...

MODULUS = int(MODULUS)

I'm sure I'm going to have to take some flak for this, though. I
wouldn't do it. What's wrong with really long lines? Anything you do
that I can see is going to obscure your code.

-D
Jul 18 '05 #3
djw
djw wrote:
Nakamura wrote:
Hi all,

Say, I have a very long integer constant , how can
I split across lines ?
I tried something like
MODULUS = 7567567567567567567567567567567\
7567507546546986094860986094860\
2345646986598695869548498698989\
...
but it doesn't compile.
Is there another way to write a long numeric constant besides writing
it as a string and then converting to long? I also wouldn't like to put
it all on one very long line.

Thanks!

Well, I _suppose_ you could do this:
MODULUS = "7567567567567567567567567567567"\
7567507546546986094860986094860"\
2345646986598695869548498698989"\
...

MODULUS = int(MODULUS)

I'm sure I'm going to have to take some flak for this, though. I
wouldn't do it. What's wrong with really long lines? Anything you do
that I can see is going to obscure your code.

-D


Oops, I forgot some quotation marks there, but you get the idea.

-D
Jul 18 '05 #4
> MODULUS = 7567567567567567567567567567567\
7567507546546986094860986094860\
2345646986598695869548498698989\
...


Seems that you cannot use line continuation for integers. Unfortunate.

However, using strings to store the value, then later converting it
doesn't incur a significant overhead, as long as you are only
initializing MODULUS once.

MODULUS = '7567567567567567567567567567567'\
'7567507546546986094860986094860'\
'2345646986598695869548498698989'\
...

MODULUS = int(MODULUS)

- Josiah
Jul 18 '05 #5

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

Similar topics

2
by: Tommy | last post by:
hi I am new to SQL.I have database of 30GB.I have just heard about spliting Databases which helps in Performance.So please can any one guide me in what are the steps involved in it. Anxious to...
1
by: Joel Rondeau | last post by:
I am building a mixed-mode DLL with VS.NET 2003 and have run across some link errors. (I have looked at the MS Help articles about LNK2020 errors with mixed-mode C++ and that has not helped)...
20
by: Opettaja | last post by:
I am new to c# and I am currently trying to make a program to retrieve Battlefield 2 game stats from the gamespy servers. I have got it so I can retrieve the data but I do not know how to cut up...
2
by: bluebeta | last post by:
Hi, I am using embedded visual C++ 4.0 and I want to use function strtok to split string into array. my sample code is as below: ...
28
by: Materialised | last post by:
Hi all, Just wondering if someone could help me with this little problem I'm having. I have a string value (it actually represents a barcode) which looks like this: 5021378002392 What I...
7
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
How do I split a title attribute value into lines within the source code so that the paragraph gets reassembled by the browser when it is being displayed? Microsoft Internet Explorer 7 preserves...
29
by: Andrea | last post by:
I want to write a program that: char * strplit(char* str1, char *str2, char * stroriginal,int split_point) that take stroriginal and split in the split_point element of the string the string...
15
by: nagar | last post by:
I need to split a string whenever a separator string is present (lets sey #Key(val) where val is a variable) and rejoin it in the proper order after doing some processing. Is there a way to use...
2
by: shadow_ | last post by:
Hi i m new at C and trying to write a parser and a string class. Basicly program will read data from file and splits it into lines then lines to words. i used strtok function for splitting data to...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.