How to output long long or int64? | Bytes (2024)

Home Posts Topics Members FAQ

Betaver

I just want to output a long long or int64 variable use printf
function.But if I use printf("%ld",x) ; I can't output an x more than
long.
I can only output it like this:
long long a,b,c;
a=c/100000000;
printf("%ld",a) ;
b=c%100000000;
printf("%08ld\n ",b);
How can I output it in an regular way?

Nov 15 '05

Subscribe Reply

26 How to output long long or int64? | Bytes (1) 104452 How to output long long or int64? | Bytes (2)

  • <
  • 1
  • 2
  • 3

Richard Bos

"Betaver" <Be*****@gmail. com> wrote:

Thanks for all the excellent answers.
My complier is gcc 3.4.2 and can't use another one, so I decide output
like this:
printf("%I64d", c);
Is it all right?

Not in C, it isn't. Maybe in Ganuck, but that's off-topic here; ask in
gnu.gcc.help (If I've remembered the name correctly; readily findable,
anyway).

Richard

Nov 15 '05 #21

Default User

Betaver wrote:

To Jordan Abel:
It's my mistake.I may wrote "__int64", not "int64"

Looks like you are trying quote messages using Google.

I think you will find the information below of value

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.

Nov 15 '05 #22

Joe Wright

Betaver wrote:

Thanks for all the excellent answers.
My complier is gcc 3.4.2 and can't use another one, so I decide output
like this:
printf("%I64d", c);
Is it all right?

Have you tried..

#include <stdio.h>
long long a;
int main(void)
{
a = 999999999;
a *= 5;
printf("%lld\n" , a);
return 0;
}

...a real C program?

With GCC 3.1 (DJGPP) this prints..
4999999995

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---

Nov 15 '05 #23

Betaver

Joe Wright wrote: With GCC 3.1 (DJGPP) this prints..
4999999995

Maybe the problem is my header file. But "%lld" isn't supported here.
Certainly "%I64d" works well.

Nov 15 '05 #24

Betaver

>Joe Wright wrote:

With GCC 3.1 (DJGPP) this prints..
4999999995

With Dev-C++ 4.9.9.2 Gcc 3.4.2

Nov 15 '05 #25

jacob navia

Betaver wrote:

Joe Wright wrote:
With GCC 3.1 (DJGPP) this prints..
4999999995

With Dev-C++ 4.9.9.2 Gcc 3.4.2

The printf you are calling is Microsoft printf in CRTDLL.DLL
Apparently you are using the mingw version of gcc without glibc.
Use I64 in that system since it works.

Nov 15 '05 #26

jacob navia

Keith Thompson wrote:

Zara <yo****@terra.e s> writes:
On 11 Nov 2005 00:05:23 -0800, "Be*****@gmail. com" <Be*****@gmail. com>
wrote:
Zara:
I use Dev-C++ 4.9.9.2, Gcc 3.4.2

#include <stdio.h>
long long a;
int main()
{
a=99999999 9;
a*=5;
printf("%lld ",a);
}

It outputs 705032699, why?

Just tried it. In GCC 3.4.2 the long long type hast 8 bytes, as
required by the standard, but it seems printf is not updated or is
broken when working with long long.

I don´t know if it works in later versions.


<SEMI-OT>
printf is part of the runtime library; it's not part of gcc.
</SEMI-OT>

Under windows they are using crtdll.dll by Microsoft.

Nov 15 '05 #27

  • <
  • 1
  • 2
  • 3

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

Similar topics

88 6032

Is it standard and practical to use long long types?

by: Matt |last post by:

Hi folks. Can you help with some questions? I gather that some types supported by g++ are nonstandard but have been proposed as standards. Are the long long and unsigned long long types still under consideration for the ANSI C and C++ standards? Are they likely to be accepted into the standards? Which compilers support those types, and which do not?

C / C++

5 23105

Printing "long double" type via printf() on MinGW g++ 3.2.3

by: Piotr B. |last post by:

Hello, I use MingGW g++ 3.2.3 on Windows 2000/AMD Athlon XP. I tried to output a "long double" variable using stdio printf(). I've tried various %formats (%llf, %Lf etc.), but none of them worked... The same source compiled with Borland C++Builder 5.0 works for %Lf format. How to get the same results with MinGW g++ ?

C / C++

1 6910

Assigning unsigned long to unsigned long long

by: George Marsaglia |last post by:

The essence of a multiply-with-carry RNG is to have declarations in the RNG proc, such as unsigned long mwc( ){ static unsigned long x = 123456789, c = 362436; unsigned long long t, a = 916905990LL; \* then reatedly form the 64-bit t = a*x+c, after which the new carry c is the top 32, and the new x (output), is the bottom 32 bits of t:

C / C++

7 5699

unsigned long long overflow?

by: dmpk2k |last post by:

Forgive me if this is obvious to you. I feel somewhat foolish. I've scribbled together something that demonstrates my problem. It takes the product of all integers n squared, where n is 1..10. ----------------- int main() { int i; unsigned long long product = 1;

C / C++

3 4034

unions with long long ints and doubles?

by: Chris N. Hinds |last post by:

I have a question regarding accessing long long ints in unions. I have constructed a union with a double, two ints in a structure, and a long long int. When the double is loaded with a floating-point constant, the double is loaded correctly, and the two ints in the structure reflect the double correctly when printed as hex values. However, when the long long is printed as a hex value (using %016x) it prints 8 zeros then the upper 32-bits...

C / C++

36 5322

extracting front bits from an unsigned long long?

by: Digital Puer |last post by:

Hi, suppose I have an unsigned long long. I would like to extract the front 'n' bits of this value and convert them into an integer. For example, if I extract the first 3 bits, I would get an int between 0 and 7 (=2^3-1). Could someone please help out? I can assume the largest returned value fits in an int. Also, I'm on a big-endian PPC (AIX), in case that matters. Ideally, I'd like to implement a prototype like: int...

C / C++

4 13357

format specifier for long long ints....

by: Ray Dillinger |last post by:

Hi. I'm using GCC on a SuSE Linux distribution, and the following program doesn't work the way I expect. I'm using the conversion specifier for long long integers that's in the man pages, but what's coming out is interpreting the lowest few bytes of the long long int as an ordinary integer. Other tests reveal that the full width is being preserved and used in calculations - it's just output that seems broken. I must have some...

C / C++

12 9527

Oracle Pro-C supports long long data type?

by: wenmang |last post by:

Hi, I am using following Oracle Proc-C compiler: Pro*C/C++: Release 8.1.7.0.0 - Production on Thu Jun 15 15:57:32 2006 (c) Copyright 2000 Oracle Corporation. All rights reserved. I like to use "long long" integer type(64 bit), but it seems that Oracle doesn't like it after execution, and giving me error code -1460, any idea about this? thx

C / C++

17 7566

Unsigned Long Long Overflow

by: Tarique |last post by:

This program was compiled on MS Visual C++ 08 /*Fibonacci Numbers*/ #include<stdio.h> #include<limits.h> void fibonacci(int n) { unsigned long long fib0 = 0;/*First Fibonacci Number*/

C / C++

9666

What is ONU?

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...

General

10199

Maximizing Business Potential: The Nexus of Website Design and Digital Marketing

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...

Online Marketing

1 10139

The easy way to turn off automatic updates for Windows 10/11

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,...

Windows Server

9020

AI Job Threat for Devs

by: agi2029 |last post by:

Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...

Career Advice

6769

Couldn’t get equations in html when convert word .docx file to html file in C#.

by: conductexam |last post by:

I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...

C# / C Sharp

5417

Trying to create a lan-to-lan vpn between two differents networks

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...

Networking - Hardware / Configuration

5551

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

2 3700

How to add payments to a PHP MySQL app.

by: muto222 |last post by:

How can i add a mobile payment intergratation into php mysql website.

PHP

3 2909

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

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...

General

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

To disable or enable advertisem*nts and analytics tracking please visit the page.

How to output long long or int64? | Bytes (2024)

FAQs

Is int64 the same as long long? ›

The __int8 data type is synonymous with type char , __int16 is synonymous with type short , and __int32 is synonymous with type int . The __int64 type is synonymous with type long long .

How to print long long int in C++? ›

unsigned long long int i=0; printf("\nenter num\n"); scanf("%llu",&i); printf("%. 20llu\n",cp); However, as mentioned earlier, unless you actually need to use this number in calculations it would be better to read and store it as a character string.

How to output long int in C? ›

Print a long int in C using putchar() only

Write a C function print(n) that takes a long int number n as argument, and prints it on console. The only allowed library function is putchar(), no other function like itoa() or printf() is allowed.

What is the format for long long integers? ›

Long Long Integers Format Specifier In C ( %lld )

To make use of such large values in input-output operations with ease, you must use the %lld format specifier. It is used to print signed integer values that are longer than even long integers.

Is Long Long always 64 bits? ›

LL refers to the long long integer type, which is at least 64 bits on all platforms, including 32-bit environments.

What is Int64 format? ›

int64. A 64-bit signed integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive).

How to return long long in C++? ›

In C++, there are specific literals provided to these data types such as for long type we use either “L” or “l” is used to identify long literal by suffixing these alphabets and for long long int we suffix with “LL” literal which are used for signed and if we want to indicate unsigned long then suffix wit “UL” and ...

How to declare long long in C? ›

To make an integer constant of type long long int , add the suffix ' LL ' to the integer. To make an integer constant of type unsigned long long int , add the suffix ' ULL ' to the integer. You can use these types in arithmetic like any other integer types.

Is long long same as long long int in C++? ›

long and long int are identical. So are long long and long long int . In both cases, the int is optional. As to the difference between the two sets, the C++ standard mandates minimum ranges for each, and that long long is at least as wide as long .

What is an example of a long int? ›

If we need to store a large integer (in the range -2147483647 to 2147483647), we can use the type specifier long . For example, // large integer long b = 123456; Note: long is equivalent to long int .

How do you convert int to long long int? ›

Using Long.

This method is a straightforward and efficient way to convert an int to a Long: int intTen = 10; Long longTen = Long. valueOf(intTen); We use the valueOf() method of the Long class to convert the int value to a Long.

What is the size of long long int in C? ›

Data Types in C
Data TypeSize (bytes)Range
long int4-2,147,483,648 to 2,147,483,647
unsigned long int40 to 4,294,967,295
long long int8-(2^63) to (2^63)-1
unsigned long long int80 to 18,446,744,073,709,551,615
9 more rows
Sep 28, 2023

How to declare a long integer? ›

Long (long integer) variables are stored as signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647. The type-declaration character for Long is the ampersand (&).

What is the range of long long int in C++? ›

Data Type Ranges and their macros in C++
Data TypeRangeMacro for min value
long long int-9223372036854775808 to +9223372036854775807LLONG_MIN
unsigned long long int0 to 18446744073709551615
float1.17549e-38 to 3.40282e+38FLT_MIN
float (negative)-1.17549e-38 to -3.40282e+38-FLT_MIN
11 more rows
Jun 24, 2024

When to use long int vs int in C? ›

Generally, you can store larger numbers in a “long int” than you can in an “int”. On most (but not all) C++ implementations, an “int” is 32 bits long and can store any number between zero and about 4 billion. But a “long int” is (typically) 64 bits and can store numbers up to 16 quadrillion.

How long is Int64? ›

Int64 represents a subset of the integer numbers. The range for the Int64 type is from -2^63 through 2^63-1 . The size of Int64 is 64 bits across all 64-bit and 32-bit platforms.

Is long long the same as uint64_t? ›

A unsigned long long int is not standardised across all systems so the size can change depending on the system running the code. A uint64_t is standardised in c++ and guarantees 64bits of storage, you need to include stdint.

What is the long data type in 64-bit? ›

long: The long data type is a 64-bit two's complement integer. The signed long has a minimum value of -263 and a maximum value of 263-1. In Java SE 8 and later, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 264-1.

What is the size limit of Int64? ›

The INT64 data type was introduced. This data type stores values outside the range of the Progress INTEGER data type from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.

References

Top Articles
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 5714

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.