[英]long long division in c
我正在嘗試傳遞“ long long”數字,問題是當我嘗試將此數字除以10時,答案不正確..
#include <stdio.h>
int main(void)
{
int n = 0 ;
long long s = 4111111111111111;
n = s % 10 ;
printf("n after modulos %i\n",n );
s = s / 10 ;
printf("this is s after division %llo \n",s );
return 0;
}
輸出:
n after modulos 1
this is s after division 13536350357330707
printf("this is s after division %llo \n",s );
^ (this prints (correct)value in octal representation)
使用說明符%lld
(獲取十進制值)。
男人3 printf
o, u, x, X
The unsigned int argument is converted to unsigned octal (o), unsigned decimal (u), or unsigned hexadecimal (x and X) notation. The letters abcdef are used for x conversions; the letters ABCDEF are
used for X conversions. The precision, if any, gives the minimum number of digits that must appear; if the converted value requires fewer digits, it is padded on the left with zeros. The default
precision is 1. When 0 is printed with an explicit precision 0, the output is empty.
還有更多關於手冊
男子3p printf
ll (ell-ell)
Specifies that a following d, i, o, u, x, or X conversion specifier applies to a long long or unsigned long long argument; or that a following n conversion specifier applies to a pointer to a long
long argument.
要long long
打印,應使用%lld
而不是%llo
%llo
格式用於表示octal
的long long
值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.