data-representation

R largest/smallest representable numbers

a 夏天 提交于 2021-02-18 09:56:05
问题 I'm trying to get the largest/smallest representable number in R. After typing ".Machine" I got: $double.xmin [1] 2.225074e-308 $double.xmax [1] 1.797693e+308 However even if I type 2.225074e-309 in R command prompt I get 2.225074e-309 instead of the expected 0 How can I find the largest/smallest number for which adding or subtracting 1 would lead to either Inf(Adding 1 to largest number) or 0(subtracting 1 from smallest number) ? 回答1: .Machine$double.xmin gives the value of the smallest

How to check whether an int variable contains a legal (not trap representation) value?

痞子三分冷 提交于 2020-01-12 23:32:08
问题 Context: This is mainly a followup to that other question. OP wanted to guess whether a variable contained an int or not, and my first thought was that in C (as in C++) an int variable could only contain an int value. And Eric Postpischil reminded me that trap representations were allowed per standard for the int type... Of course, I know that most modern system only use 2-complement representations of integers and no padding bits, meaning that no trap representation can be observed.

How to check whether an int variable contains a legal (not trap representation) value?

这一生的挚爱 提交于 2020-01-12 23:31:24
问题 Context: This is mainly a followup to that other question. OP wanted to guess whether a variable contained an int or not, and my first thought was that in C (as in C++) an int variable could only contain an int value. And Eric Postpischil reminded me that trap representations were allowed per standard for the int type... Of course, I know that most modern system only use 2-complement representations of integers and no padding bits, meaning that no trap representation can be observed.

How to represent complex and hybrid data

╄→гoц情女王★ 提交于 2020-01-04 02:14:50
问题 I have a quite complicated question. I'm looking for a javascript or PHP script that can take about any data (arrays, mysql queries ...) and make a table / pivot table / chart of it. to be simple, I want an app that is able to take any data and represent it as we ask. For example take content rated by a user. I want to be able to make a graph of the number of person that rated 1,2,3,4 or 5. I want to make a table with the number of users that rated in july and in august. I want to get the

MYSQL hide field data if value in another field is set

霸气de小男生 提交于 2020-01-03 05:10:25
问题 Got a table like: art. type price a b 1 a c 2 would it be possible with a select to show filtered content as: art. type price a b a c 2 so that if the type is "b" don't show price data? select art, type, price from x where type="b" hide price 回答1: Logic of this sort probably best belongs in the presentation, rather than database, layer of your application. However, it is nevertheless possible using either MySQL's IF() function or its CASE expression—for example: SELECT art, type, IF(type='b'

Representing dynamic typing in C

戏子无情 提交于 2019-12-29 04:43:46
问题 I'm writing a dynamically-typed language. Currently, my objects are represented in this way: struct Class { struct Class* class; struct Object* (*get)(struct Object*,struct Object*); }; struct Integer { struct Class* class; int value; }; struct Object { struct Class* class; }; struct String { struct Class* class; size_t length; char* characters; }; The goal is that I should be able to pass everything around as a struct Object* and then discover the type of the object by comparing the class

Pygraphviz / networkx set node level or layer

旧街凉风 提交于 2019-12-17 19:30:14
问题 I have a dataset that represents a kind of genealogy tree. Each node has 2 parents (except first generation, they have no parents). For a given node, its parents can be from any previous generation. For example a node in generation n, can have a parent in n-1, and another parent in n-5. A node can be parent of several other nodes. So basically, for every node I know its generation and its parents. I am trying to represent this graph keeping the nodes from the same generation in the same line.

ASCII table and character presentation

假装没事ソ 提交于 2019-12-13 05:07:55
问题 We learn in class about ASCII table, and that every character from 128 characters has a unique number from 0-128 representing it. For example "a" is 97 (in binary 97 is 1100001). "%" is 37 (and in binary 37 is 0100101). (I understand that for a fixed length of 7 we should allow the binary number start with 0) If 97 is representing "a", then what represents the string "97"? What represents the integer 97? 回答1: I think your question is based on the notion that, given a representation of an

Creating a 'thermal image' using data points

依然范特西╮ 提交于 2019-12-12 09:52:26
问题 I am looking for a way to represent some data points into a 'thermal map' (500x500). Data array: "data": [ { "x": 120, "y": 350, "temperature": 90 }, { "x": 300, "y": 210, "temperature": 35 }, { "x": 450, "y": 50, "temperature": 68 }, ] This array should be processed into something like this using CSS and Javascript: (Very roughly) What would be the best way to approach this using Javascript and CSS? 回答1: To draw circles with gradient translucency, use radial gradients. To position them, use

9-bit floating point representations using IEEE floating point format A and B

社会主义新天地 提交于 2019-12-02 06:41:07
I'm having some trouble with a problem I've run into dealing with floating points. I'm having a hard time moving from floating point representation to decimal values and also from format A of the representation to format B of the representation. The problem: Consider the following two 9-bit floating-point representations based on the IEEE floating-point format. Format A There is one sign bit. There are k = 5 exponent bits. The exponent bias is 15. There are n = 3 fraction bits. Format B There is one sign bit There are k = 4 exponent bits. The exponent bias is 7. There are n = 4 faction bits