limits

How would you set a variable to the largest number possible in C?

て烟熏妆下的殇ゞ 提交于 2019-11-27 09:02:41
How would you set a variable to equal infinity (or any guaranteed largest number value) in C? #include <limits.h> int x = INT_MAX; EDIT: answered before the questioner clarified, I was just guessing what type they wanted. There is a file called limits.h (at least on Linux there is), which holds this kind of definition e.g. /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */ # define USHRT_MAX 65535 /* Minimum and maximum values a `signed int' can hold. */ # define INT_MIN (-INT_MAX - 1) # define INT_MAX 2147483647 /* Maximum value an `unsigned int' can hold. (Minimum is 0.) *

How many times can a file be compressed?

孤街醉人 提交于 2019-11-27 06:36:01
I was thinking about compression, and it seems like there would have to be some sort of limit to the compression that could be applied to it, otherwise it'd be a single byte. So my question is, how many times can I compress a file before: It does not get any smaller? The file becomes corrupt? Are these two points the same or different? Where does the point of diminishing returns appear? How can these points be found? I'm not talking about any specific algorithm or particular file, just in general. Nosredna For lossless compression, the only way you can know how many times you can gain by

How to portably find out min(INT_MAX, abs(INT_MIN))?

吃可爱长大的小学妹 提交于 2019-11-27 06:34:02
问题 How can I portably find out the smallest of INT_MAX and abs( INT_MIN )? (That's the mathematical absolute value of INT_MIN , not a call to the abs function.) It should be as same as INT_MAX in most systems, but I'm looking for a more portable way. 回答1: While the typical value of INT_MIN is -2147483648, and the typical value of INT_MAX is 2147483647, it is not guaranteed by the standard. TL;DR: The value you're searching for is INT_MAX in a conforming implementation. But calculating min(INT

Relative positioning of geom_text in ggplot2?

≯℡__Kan透↙ 提交于 2019-11-27 04:31:34
问题 I am using geom_text to annotate plots in gglot2 and I want use relative positioning rather than absolute. That is, I want a position of (0.5, 0.5) to be dead center regardless of the x and y axis limits. Is that possible? Alternatively I could of course transform a relative position to an absolute one if I had the x and y limits. Is it possible to extract those from a plot? 回答1: If you know the range of the data in your plot, you can calculate the "true" x and y limits using the fact that

C++ variable types limits

拜拜、爱过 提交于 2019-11-27 03:18:45
问题 here is a quite simple question(I think), is there a STL library method that provides the limit of a variable type (e.g integer) ? I know these limits differ on different computers but there must be a way to get them through a method, right? Also, would it be really hard to write a method to calculate the limit of a variable type? I'm just curious! :) Thanks ;). 回答1: Use std::numeric_limits: // numeric_limits example // from the page I linked #include <iostream> #include <limits> using

How do I increase the /proc/pid/cmdline 4096 byte limit?

寵の児 提交于 2019-11-26 22:55:53
问题 For my Java apps with very long classpaths, I cannot see the main class specified near the end of the arg list when using ps. I think this stems from my Ubuntu system's size limit on /proc/pid/cmdline. How can I increase this limit? 回答1: You can't change this dynamically, the limit is hard-coded in the kernel to PAGE_SIZE in fs/proc/base.c: 274 int res = 0; 275 unsigned int len; 276 struct mm_struct *mm = get_task_mm(task); 277 if (!mm) 278 goto out; 279 if (!mm->arg_end) 280 goto out_mm; /*

Maximum number of parameters in function declaration

做~自己de王妃 提交于 2019-11-26 18:03:57
问题 I know that minimum number of parameters in function definition is zero, but what is the maximum number of parameters in function definition? I am asking the question just for the sake of knowledge and out of curiosity, not that I am going to write a real function. 回答1: Yes, there are limits imposed by the implementation. Your answer is given in the bold text in the following excerpt from the C++ Standard. 1. C++ Language Annex B - Implementation quantities Because computers are finite, C + +

How would you set a variable to the largest number possible in C?

梦想的初衷 提交于 2019-11-26 17:47:58
问题 How would you set a variable to equal infinity (or any guaranteed largest number value) in C? 回答1: #include <limits.h> int x = INT_MAX; EDIT: answered before the questioner clarified, I was just guessing what type they wanted. 回答2: There is a file called limits.h (at least on Linux there is), which holds this kind of definition e.g. /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */ # define USHRT_MAX 65535 /* Minimum and maximum values a `signed int' can hold. */ # define

Memory errors and list limits?

六眼飞鱼酱① 提交于 2019-11-26 16:09:06
I need to produce large and big (very) matrices (Markov chains) for scientific purposes. I perform calculus that I put in a list of 20301 elements (=one row of my matrix). I need all those data in memory to proceed next Markov step but i can store them elsewhere (eg file) if needed even if it will slow my Markov chain walk-through. My computer (scientific lab): Bi-xenon 6 cores/12threads each, 12GB memory, OS: win64 Traceback (most recent call last): File "my_file.py", line 247, in <module> ListTemp.append(calculus) MemoryError Example of calculus results: 9.233747520008198e-102 (yes, it's

Limit ggplot2 axes without removing data (outside limits): zoom

只谈情不闲聊 提交于 2019-11-26 15:14:21
If you specify axis limits in ggplot the outlying points are removed. This is fine for points, but you might want to plot lines that intersect with the specified range, but ggplot's range or xlim/ylim methods removes these. Is there another way to specify the plot axis range without removing outlying data? e.g. require(ggplot2) d = data.frame(x=c(1,4,7,2,9,7), y=c(2,5,4,10,5,3), grp=c('a','a','b','b','c','c')) ggplot(d, aes(x, y, group=grp)) + geom_line() ggplot(d, aes(x, y, group=grp)) + geom_line() + scale_y_continuous(limits=c(0,7)) ggplot(d, aes(x, y, group=grp)) + geom_line() + ylim(0,7)