Skip to content

Instantly share code, notes, and snippets.

Yoshio HANAWA hnw

Block or report user

Report or block hnw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hoge.md
{
   "foo": [3,4,5]
}
View hoge.md

ECMAScriptの浮動小数点数の丸め仕様が素晴らしい話

ECMAScriptの浮動小数点数の丸め関数である Number.prototype.toFixed() の仕様を調べてみたところ、仕様自体が素晴らしいと感じたので紹介します。

浮動小数点数の丸めの善し悪しについて

私はプログラミング言語の浮動小数点数の丸め処理に興味があり、過去に関連記事を30本近く書いています。こうした活動から得られた知見として、良い丸め関数には次のような性質があると考えています。

  • 仕様がシンプルで直感的であること
  • 仕様が抜け漏れなく文書化されていること
View 1092104.json
{
"title": "Use Japanese Keyboard as US Keyboard",
"rules": [
{
"description": "Ctrl+@ to Escape",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "open_bracket",
View 1092104.json
{
"title": "Use Japanese Keyboard as US Keyboard (rev 1)",
"rules": [
{
"description": "Ctrl+@ to Escape",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "open_bracket",
View 1092104.json
{
"title": "Remap Japanese Keyboard to US (rev 1)",
"rules": [
{
"description": "Ctrl+@ to Escape",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "open_bracket",
View 1092104.json
{
"title": "Remap Japanese Keyboard to US",
"rules": [
{
"description": "Ctrl+@ to Escape",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "open_bracket",
View deployment-manager-types-list-20181113.txt
---
provider: gcp-types/appengine-v1
types:
- apps
- apps.locations
- apps.authorizedCertificates
- apps.services
- apps.services.versions
- apps.services.versions.instances
- apps.authorizedDomains
View bitshift.c
#include <stdio.h>
#include <limits.h>
int main()
{
long i1 = -1;
long i2 = LONG_MIN; // -9223372036854775808
unsigned long u = ULONG_MAX; // 18446744073709551615
printf("%ld\n", i1>>1); // 最上位ビット維持、算術シフト (-1)
View hoge999.php
<?php
abstract class Foo {
abstract public function func(int $y);
}
class Bar extends Foo {
public function func(int $y) {
return 1;
}
View log-localtime.go
package main
import (
"log"
"time"
)
func main() {
log.Fatalf("Now() = %s", time.Now())
You can’t perform that action at this time.