mantissa

Shader Time Uniform - clock_gettime being truncated

时光怂恿深爱的人放手 提交于 2019-12-13 16:13:09
问题 Take this function getting time as a double using clock_gettime: // return current time in milliseconds static double time_get_ms(void) { struct timespec res; #ifdef ANDROID clock_gettime(CLOCK_REALTIME_HR, &res); #else clock_gettime(CLOCK_REALTIME, &res); #endif return (double)(1000.0*res.tv_sec + res.tv_nsec/1e6); } Sending it to a shader requires conversion to float. The mantissa is being overflowed and is truncated on the way to the shader. Example: As a double = 1330579093642.441895 As a

How to find mantissa length on a particular machine?

瘦欲@ 提交于 2019-12-06 06:39:36
问题 I'm wanting to find the number of mantissa digits and the unit round-off on a particular computer. I have an understanding of what these are, just no idea how to find them - though I understand they can vary from computer to computer. I need this number in order to perform certain aspects of numerical analysis, like analyzing errors. What I'm currently thinking is that I could write a small c++ program to slowly increment a number until overflow occurs, but I'm not sure what type of number to

Fractional Part of NSDecimalNumber

两盒软妹~` 提交于 2019-12-05 22:49:39
问题 I'm using NSDecimalNumber to store a value for currency. I'm trying to write a method called "cents" which returns the decimal portion of the number as an NSString with a leading 0 if the number is < 10. So basically NSDecimalNumber *n = [[NSDecimalNumber alloc] initWithString:@"1234.55"]; NSString *s = [object cents:n]; And I'm trying to craft a method that will return 01, 02, etc...up to 99 as a string. I can't seem to figure out how to return the mantissa as a string in this format. I feel

How to find mantissa length on a particular machine?

给你一囗甜甜゛ 提交于 2019-12-04 12:42:41
I'm wanting to find the number of mantissa digits and the unit round-off on a particular computer. I have an understanding of what these are, just no idea how to find them - though I understand they can vary from computer to computer. I need this number in order to perform certain aspects of numerical analysis, like analyzing errors. What I'm currently thinking is that I could write a small c++ program to slowly increment a number until overflow occurs, but I'm not sure what type of number to use. Am I on the right track? How exactly does one go about calculating this? I would think that

Fractional Part of NSDecimalNumber

ぃ、小莉子 提交于 2019-12-04 05:27:19
I'm using NSDecimalNumber to store a value for currency. I'm trying to write a method called "cents" which returns the decimal portion of the number as an NSString with a leading 0 if the number is < 10. So basically NSDecimalNumber *n = [[NSDecimalNumber alloc] initWithString:@"1234.55"]; NSString *s = [object cents:n]; And I'm trying to craft a method that will return 01, 02, etc...up to 99 as a string. I can't seem to figure out how to return the mantissa as a string in this format. I feel like I'm missing a convenience method but I looked at the documentation again and don't see anything

How to change the the number of digits of the mantissa using offset notation in matplotlib colorbar

感情迁移 提交于 2019-12-02 02:58:25
问题 I have a contour plot in matplotlib using a colorbar which is created by from mpl_toolkits.axes_grid1 import make_axes_locatable divider = make_axes_locatable(axe) #adjust colorbar to fig height cax = divider.append_axes("right", size=size, pad=pad) cbar = f.colorbar(cf,cax=cax) cbar.ax.yaxis.set_offset_position('left') cbar.ax.tick_params(labelsize=17)#28 t = cbar.ax.yaxis.get_offset_text() t.set_size(15) How can I change the colorbar ticklabels (mantissa of exponent) showing up with only 2

How to change the the number of digits of the mantissa using offset notation in matplotlib colorbar

你说的曾经没有我的故事 提交于 2019-12-02 01:25:30
I have a contour plot in matplotlib using a colorbar which is created by from mpl_toolkits.axes_grid1 import make_axes_locatable divider = make_axes_locatable(axe) #adjust colorbar to fig height cax = divider.append_axes("right", size=size, pad=pad) cbar = f.colorbar(cf,cax=cax) cbar.ax.yaxis.set_offset_position('left') cbar.ax.tick_params(labelsize=17)#28 t = cbar.ax.yaxis.get_offset_text() t.set_size(15) How can I change the colorbar ticklabels (mantissa of exponent) showing up with only 2 digits after the '.' instead of 3 (keeping the off set notation)? Is there a possibility or do I have

How does double to int cast work in Java

£可爱£侵袭症+ 提交于 2019-11-27 01:49:01
I am new to Java, and wondering how does double to int cast work ? I understand that it's simple for long to int by taking the low 32 bits, but what about double (64 bits) to int (32 bits) ? those 64 bits from double in binary is in Double-precision floating-point format (Mantissa), so how does it convert to int internally ? Jon Skeet It's all documented in section 5.1.3 of the JLS. In the first step, the floating-point number is converted either to a long, if T is long, or to an int, if T is byte, short, char, or int, as follows: If the floating-point number is NaN (§4.2.3), the result of the

How does double to int cast work in Java

自闭症网瘾萝莉.ら 提交于 2019-11-26 09:46:01
问题 I am new to Java, and wondering how does double to int cast work ? I understand that it\'s simple for long to int by taking the low 32 bits, but what about double (64 bits) to int (32 bits) ? those 64 bits from double in binary is in Double-precision floating-point format (Mantissa), so how does it convert to int internally ? 回答1: It's all documented in section 5.1.3 of the JLS. In the first step, the floating-point number is converted either to a long, if T is long, or to an int, if T is