|
Hi,
I have vc++ 2005.I download the lint library , Where to paste the lint.h file and lint.cpp ?
I paste it in include folder.Then Copy the code given on the net.It geives error like
For stmt:
lint a;
Identifier error.
Can u tell me complete procedure to run given program.
Is there any setting required...
Vishnu
|
|
|
|
|
lint a=2;
lint b=3;
lint c=1;
lint d=4;
lint e=8;
lint x, y, z;
x = (d*e)+(a*b); // math shouldn't be a problem.
printf( "x base 16 = %s\n", x.value(16) );//Present 40
printf( "x base 10 = %s\n", x.value(10) );//Present 64 have to be 32+6=38
|
|
|
|
|
lint a=2;
lint b=3;
lint c=1;
lint d=4;
lint e=8;
lint x, y, z;
x = (d*e)+(a*b); // math shouldn't be a problem.
printf( "x base 16 = %s\n", x.value(16) );//Present 40
printf( "x base 10 = %s\n", x.value(10) );//Present 64 have to be 32
|
|
|
|
|
hi everyone.
just writing to say i've been searching the web for a minimal, simple to use, large number library, and after hours wasted, i found this beauty.
thanks!
|
|
|
|
|
The folks at The Code Project have given my little project an approved location at:
http://www.codeproject.com/cpp/lint.asp
Please post comments there - I will bring remove this site on Jan. 1, 2006.
Jeremy Wilson
mitselplik@cox.net
|
|
|
|
|
lint a = 1234; lint b = 1234; lint c = a*b; will cause an error. please check.
|
|
|
|
|
Ran the following with VC++ that comes with Visual Studio .Net 2003
#include "lint.h"
#include <stdio.h>
int main() {
lint a = 1234;
lint b = 1234;
lint c = a * b;
printf( "c base 10 = %s\n", c.value() );
printf( "Press enter to quit.\n" );
getchar();
return 0;
}
It ran just fine. Could you provide a little more detail about the error you are getting?
Jeremy Wilson
mitselplik@cox.net
|
|
|
|
|
The following is my test code, on VS.net 2003.
runtime error also, but not same as vc6.0
#include "stdafx.h"
#include "lint.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
lint a = 1234;
lint b = 1234;
lint c = a*b;
cout<
|
|
|
|
|
I created a project, copy and pasted your code into it, and removed the third line that just has an #include all by itself. When I compiled and ran the code, it ran fine. At this point, it appears to be a problem with your compiler, or perhaps some setting you are using.
Try just declaring a lint variable and see if it gives you a valid address in memory. Then assign a value to it in a separate statement.
If I had to guess, it would 'seem' that the compiler thinks you are declaring a pointer to a lint and not an actual lint. For example,
lint *a = 1234;
will generate an error like what you are seeing. In this case, the code is declaring a pointer to an object that doesn't exist.
Jeremy Wilson
mitselplik@cox.net
|
|
|
|
|
Hi jeremy:
I tried to compile to release version instead of debug, it runs ok.
and remove asm codes in the operator=, instead of equivalent c code. run ok.
I think maybe some different between debug and release.
|
|
|
|
|
I have found the bug:
for VC compiler, at start of a function, will fill the stack with 0xcccccccc, using "rep stos". and many rep stos in your coding. when you insert std, rep stosd..., you must restore direction flag using cld. in order to avoid error, you'd better insert pushfd at begin, and popfd at end in _asm{}.
again: can you finish the hex string? "abcdef0123456789"...?
Thanks.
|
|
|
|
|
Hello,
good idea, but a bit strange (well, a naive?) implementation:
1. Single-threaded in principle. You can't even use _different_ instance of LINT in _different_ threads. See implementation of many operators - using static temporary buffers.
2. Many operators could be inlined as they are just wrappers over the others.
3. Assembler intensive use. That's one of the biggest disadvantage of this code.
a) it's not portable.
b) it's not always optimal, for instance SSE-based memory copy is faster than lodsd/stosd, then AFAIK on modern CPU Intel suggest not to use string commands (with loop) at all, as a simple "hand-made" loop works faster.
c) it's not scaled automatically with a new 64-bits CPUs.
d) you loose possibility to use compiler manufacturer optimized memcpy / memcmp functions (often inlined too).
4. It's not template-based. What if I need lint of 512, 1024 and 2048 bits in a one program?
My conclusion: a 1995-year style based exercise from C++ book with some assembler chunks.
I hope you check my notes and make library better (if you have time of course).
--
WBR, Nick
|
|
|
|
|
This is my first attempt at posting code I wrote Your criticism is solid and well accepted I think I will take you up on the challenge and dig in to some deeper research, write a better article about what I have found (or not found) and submit a better library
The only issue I have is 3a - I didn't want portable code - I wanted code into which I could intentionally put inline assembler code in order to hand optimize it where possible and learn (and teach) better inline assembly techniques. Adding SSE extensions, for example, is on my "To Do" list
Thanks for the great advice
Jeremy Wilson
mitselplik@cox.net
|
|
|
|
|
A very nice article and module. Can I suggest you create a project on SourceForge? Using CodeProject alone is not likely to propogate improvements or bugfixes easily. Because of this, many people will possibly remain wary.
Great work though.
Graham
|
|
|
|
|
I submitted a request for a SourceForge project when I created this Code Project page. I have yet to hear anything back.
Jeremy Wilson
mitselplik@cox.net
|
|
|
|
|
you say :"// math shouldn't be a problem."
but what about mathematic functions ?
how could i perform cosine calculation on it, squared root, logarithm, etc... ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
|
|
|
|
|
You should consider a high precicion floating library.
I think this library is for large integers...hence the name...
-y
|
|
|
|
|
|
Your code is very impressive.
In what ways is your class superior to the BigInteger class found in the J# library? Obviously, your class can be compiled into the assembly and, presumably, could be used in an unmanaged code project, but other than the obvious ways...
I am not a C++ developer, but was very interested in your article, nonetheless.
Thanks!
Kevin Buchan
|
|
|
|
|
The java.math.BigInteger class is an arbitrary precision class. As such, it has more overhead to deal with dynamic memory allocation and such. I don't know how much overhead though - I'd love to get under its covers and see how it works.
If I get a chance, I'll write a couple of programs to profile both my code and the java library code and see how they compare.
Jeremy Wilson
mitselplik@cox.net
|
|
|
|
|
your project has very unhappy name.. Lint means for years something else in C++ world.. Try to search for it by Google and you will see what I mean..
|
|
|
|
|
I am aware of the lint tool that programmers use to check their "C" code, but to my knowledge, this tool is not used to check "C++" code. The languages, while similar for obvious reasons, are in fact, remarkably different. I could be wrong however - its been years since I used any tools outside the standard tools available in the IDE for VC++.
I would also like to point out that many words in any given language have been used to name completely different things. Recognizing that I was giving an old name to a new thing, I chose to qualify my title with a colon and short description so as to eliminate confusion for someone doing a web search.
Now you have me curious though. My use of the word actually makes sense. I wonder how the original authors of lint came up with that name for their code analysis and profiling tool.
Jeremy Wilson
mitselplik@cox.net
|
|
|
|
|
|
My understanding is that the term "lint" was used because furniture makers would use handfuls of fluff (lint) to rub across the surface of the wood to help identify imperfections. The lint would catch on areas that needed better sanding and would, therefore, point out the areas of the project that required review.
|
|
|
|
|
PC-lint checks both C and C++ code.
http://www.gimpel.com/
It's a command line tool, which is nice because you can add it as a Tool to Visual Studio and direct its output to the Output window. It even supports options to output warnings in a format that allows you to go to the source line with a double click.
Running PC-lint on your code results in 154 warnings at warning level 3, using my custom options. There are many "Info 1747: binary operator returning a reference" warnings. There are also a number of warnings as a result of sloppy programming, some of them potentially serious. You can download a description of all warnings on Gimpel's web site.
My experience is that the free open source lint utilities (e.g., splint) pale in comparison to PC-lint. It seems the frustration people experience in trying to get the free lint utilities to work often results in the same people giving lint a bad name. When it comes to free lint, you get what you pay for. When it comes to PC-lint, you get way more than you pay for.
|
|
|
|