样式浮动表头(Style floating table headers)
所以我一直在努力让浮动表头工作。 不幸的是我不能使用像floatThead jQuery库这样的东西,因为我需要在滚动表格时悬停不同的行,所以我基于各种其他SO答案提出了我自己的解决方案。
但是,问题是浮动标题的样式与非浮动标题的样式不匹配,我不确定为什么是这样或正确的方法来解决这个问题。
这是一个说明我当前代码的jsFiddle 。 问题是具有不同列的第一个浮动标头与非浮动标头的大小不匹配,即使它们都具有百分比宽度(加起来为100%)。
重要的javascript:
var persist = $(".persist-area"); var z_index = 900; var count = 0; persist.each(function() { var el = $(".persist-thead>tr", this); el.before(el.clone()).css({"width": el.width(), "top": "0px", "z-index": "899"}).addClass('floating-thead'); $(".persist-header", this).each(function() { var clone = $(this); clone.before(clone.clone()).css({ "width": clone.width(), "top": (0 + el.height()) + "px", "z-index": "" + z_index }).addClass("floating-header").removeClass("persist-header").attr('id', 'floating-header-' + count); z_index++; count++; }); });
和css:
.floating-thead, .floating-header { position: fixed; top: 0; visibility: hidden; } .floating-thead > td, .floating-header > td { display: inline-block; text-align: center; }
So I've been trying to accomplish getting floating table headers to work. Unfortunately I cannot use something like floatThead jQuery library as I need to hover different rows as you scroll through the table so I've come up with my own solution based on various other SO answers.
However, the problem is that the styling of the floating header does not match the styling of the non-floated header and I'm not sure why that is or the proper way to fix this.
Here's a jsFiddle illustrating my current code. The issue is that the first floating header which has different columns does not match the sizing of the non-floating header even though they both have percentage widths (that add up to 100%).
The important javascript:
var persist = $(".persist-area"); var z_index = 900; var count = 0; persist.each(function() { var el = $(".persist-thead>tr", this); el.before(el.clone()).css({"width": el.width(), "top": "0px", "z-index": "899"}).addClass('floating-thead'); $(".persist-header", this).each(function() { var clone = $(this); clone.before(clone.clone()).css({ "width": clone.width(), "top": (0 + el.height()) + "px", "z-index": "" + z_index }).addClass("floating-header").removeClass("persist-header").attr('id', 'floating-header-' + count); z_index++; count++; }); });
and css:
.floating-thead, .floating-header { position: fixed; top: 0; visibility: hidden; } .floating-thead > td, .floating-header > td { display: inline-block; text-align: center; }
原文:https://stackoverflow.com/questions/39665883
最满意答案
这是一个棘手的问题。
浮点格式定义了一些特殊值。 您是否将这些视为不同取决于您的观点。 以下是双精度(binary64):
- 有两个0的表示:符号位0或1,指数和尾数都为零。 这些值可通过1 / + 0 =无穷大和1 / -0 = -infinity的事实来区分。 但他们比较平等。
- 有2个无穷大,其中前12位是0x7ff或0xfff,尾数全为零。 这些不是有限的实数,但它们是值。
- 存在整个范围的非数字(NaN)值,具有符号+指数位0x7ff(信令NaN)或0xfff(“安静”NaN)和非零尾数。 同样,这些不是实数,但它们是可区分的值。
所以,总结一下:
- 可区分值的总数(实数或其他)是2 ^ 64。
- 不包括无穷大且仅计数零一次的不同实数的数量是
2*(2^11-1)*2^52-1 = 18,437,736,874,454,810,623
。对于binary16,不同实数的数量是
2*(2^5-1)*2^10-1 = 63,487
。 对于binary32,它是2*(2^8-1)*2^23-1=4,278,190,079
。 对于binary128,它是2*(2^15-1)*2^112-1
或大约3.4*10^38
。This is a trick question.
The floating-point formats define some special values. Whether you count these as distinct depends on your point of view. The following is for double-precision (binary64):
- There are two representations of 0: with the sign bit 0 or 1 and both the exponent and mantissa all zero. The values are distinguishable by the fact that 1/+0 = infinity and 1/-0 = -infinity. But they compare equal.
- There are 2 infinities, where the first 12 bits are 0x7ff or 0xfff and the mantissa is all zero. These are not finite real numbers, but they are values.
- There is a whole range of Not-A-Number (NaN) values, having sign+exponent bits 0x7ff (signaling NaN) or 0xfff ("quiet" NaN) and a nonzero mantissa. Again, these are not real numbers but they are distinguishable values.
So, to summarize:
- The total number of distinguishable values (real numbers or otherwise) is 2^64.
- The number of distinct real numbers, excluding infinities and counting zero only once, is
2*(2^11-1)*2^52-1 = 18,437,736,874,454,810,623
.For binary16, the number of distinct real numbers is
2*(2^5-1)*2^10-1 = 63,487
. For binary32, it's2*(2^8-1)*2^23-1=4,278,190,079
. For binary128, it's2*(2^15-1)*2^112-1
or about3.4*10^38
.
相关问答
更多-
为什么更高精度的浮点格式具有如此多的指数位?(Why do higher-precision floating point formats have so many exponent bits?)[2024-03-06]
当英特尔开始创建8087数学协处理器时,加州大学伯克利分校的教授William Kahan已经完成了IEEE-754浮点标准的工作。 成为IEEE-754浮点格式的设计标准之一是尽可能与现有专有浮点格式的功能兼容性。 这本书 John F. Palmer和Stephen P. Morse,“8087 Primer”。 Wiley,纽约1984。 特别提到了CDC 6600的60位浮点格式,相对于双精度格式,具有11位指数和48位尾数。 以下公布的访谈(令人费解地将Jerome Coonen的名字改为Gero ... -
不要使用2^16-1 。 使用2^16 。 是的,你的精度会略微降低并浪费你的0xFFFF ,但你会保证在转换到浮点时不会有精度损失。 (相反,当从浮点转换时,您将失去8位的mantissal精度。) 精度之间的往返转换可能导致某些操作出现问题,特别是逐步求和数字。 如果可能的话,将定点值视为“脏”,不要将它们用于进一步的浮点计算; 更喜欢从输入重新计算到使用定点形式的中间结果。 或者,使用24位。 使用此表示,只要您的值不下溢(即,只要它们高于2^-24 ),您就不会在任何方向上失去任何精度。 Don't ...
-
浮点平等和不平等(Floating-point equality and inequality)[2023-06-27]
是的,这将永远为真,没有数字解释的位模式,运算符==将不会返回完全相反的!=。 对于不同的位模式(负零点0x80 ...等于零0x00 ...)进行比较的位模式有异常,或者与您已经提到的相同的位模式比较为不等(NaN),但是!=总是==的反转。 Yes, this will be always true, there are no number interpretations of bit patterns for which the operator == will not return the exac ... -
将64位浮点格式字符串转换为浮点数(Convert 64-bits floating-point format string to floating-point number)[2024-01-21]
你可以使用struct.unpack 。 >d是big-endian double; 请参阅help(struct)了解更多信息! import struct d, = struct.unpack('>d', b'\xc0\x6f\xca\x5e\x35\x00\x00\x00') print(d) # -254.32399988174438 如果您的字符串确实是'C06FCA5E35000000' ,则可以使用binascii.a2b_hex将其首先转换为字节。 You can use struct ... -
感谢您报告这一点。 我们已经解决了这个问题 ,并且已经与CrateDB 1.1.3(stable)一起发布。 作为一个方面说明: 此改进检查包含算术运算符和小数值的表达式是否仅包含float类型。 如果是这种情况,则结果数据类型将是float类型。 如果表达式包含double类型的十进制值,则行为与之前类似,结果类型也将是double类型的表示形式。 Thanks for reporting this. We fixed this issue already and it has also been rel ...
-
这是一个棘手的问题。 浮点格式定义了一些特殊值。 您是否将这些视为不同取决于您的观点。 以下是双精度(binary64): 有两个0的表示:符号位0或1,指数和尾数都为零。 这些值可通过1 / + 0 =无穷大和1 / -0 = -infinity的事实来区分。 但他们比较平等。 有2个无穷大,其中前12位是0x7ff或0xfff,尾数全为零。 这些不是有限的实数,但它们是值。 存在整个范围的非数字(NaN)值,具有符号+指数位0x7ff(信令NaN)或0xfff(“安静”NaN)和非零尾数。 同样,这些不 ...
-
浮点格式和isinf()(Floating point formats and isinf())[2022-10-28]
isinf ,来自cmath的函数旨在与C语言兼容,需要double 。 传递给该函数时, long double参数会以静默方式转换为double 。 转换为double会根据浮点舍入规则生成+inf (任何大于限制的数字本身略大于DBL_MAX都会舍入为+inf )。 相比之下, std::isinf 过载并且需要很long double 。 当你传递一个long double ,参数不会被转换, std::isinf可以告诉它不是无限的。 要尝试回答您的其他问题: isinf是宏还是函数是一个小细节。 ... -
准确预测任意浮点格式之间的转换舍入误差(Accurately predicting rounding error of cast between arbitrary floating-point formats)[2022-07-26]
以下内容可能有效: double isbad(double x, double releps) { double y = x * (1 + 0x1.0p29); double z = y-x-y+x; return !(fabs(z/x) < releps); } 这使用了一种技巧(由于Dekker,我相信)将浮点数分成“大半”和“小半”,它们与原始数字完全相加。 我希望“大半”有23位而“小半”有其余的,所以我使用常数1 + 2 ^(52-23)进行分割。 注意事项:您需要通过检查上限和下限 ... -
看看这里的sscanf文档,如果你想要一个字符串浮点数,你需要指定格式。 以下是此页面中与您类似的示例: tempString = '78°F 72°F 64°F 66°F 49°F'; degrees = char(176); tempNumeric = sscanf(tempString, ['%d' degrees 'F'])' tempNumeric = 78 72 64 66 49 在您的具体情况下,您可以尝试: val = sscanf(rangedata,' ...
-
根据定义,有效数是基数β中的p“数字”序列,其中基数β中的数字是β可能值之一,从表示0的数字到表示β-1的数字。 p个数字的序列有多少选择,其中每个数字都有β个可能的值? 答案是βp :第一个数字有β选择,第二个数字有β选择,可以独立于第一个数字选择,依此类推。 例如,可以在β*β或β2值中选择两位数的有效数。 对于一个更具体的例子,在十进制(β= 10)中,有1000个有效数字,长度为3,从000到999.这1000种可能性可以用10位编码,仔细编码(编码4位中的每个十进制数字)不行,但更复杂的东西,因为 ...