This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple illustration for how quickly you can end up with a (float/double) rounding error | |
* using even single digit (past decimal point) precision numbers for floats and longs | |
* | |
* you can try yourself, the results should both be (0) | |
*/ | |
public class Java_float_double_RoundingError { | |
public static void main (String[] args) { | |
//add (3) identical floats then subtract (3) identical floats (should be 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.lang.System.*; | |
/** | |
* Helps explaining how one might use System.out.printf to | |
* format whole decimal numbers to the console | |
* | |
Program Output: | |
12345 X format "%10d X" | |
-12345 X format "%10d X" | |
12345 X format "%-10d X" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gist.basics; | |
import com.typestruct.field.Bind; | |
import com.typestruct.frame.Frame.Field; | |
import com.typestruct.frame.word.WordFrame; | |
import com.typestruct.synthesize.Synthesize; | |
import com.typestruct.type.custom.DayInRangeType; //this is a "custom" user defined type | |
/** | |
* typestruct provides a simple API for representing, collecting, analyzing, and manipulating data in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gist.basics; | |
import com.typestruct.field.Bind; | |
import com.typestruct.field.Bind.Modify; | |
import com.typestruct.frame.word.WordFrame; | |
/** | |
* Example illustrating the use of <B>Bucketizers</B> which | |
* are Type.Binding <B>Modifier</B>s applied to | |
* field bindings within a <CODE>WordFrame</CODE>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gist.basics; | |
import com.typestruct.field.Bind; | |
import com.typestruct.frame.Frame; | |
import com.typestruct.frame.word.WordFrame; | |
/** | |
* Example illustrating the use of unsigned primitive field bindings | |
* (uByte8, uShort16, uInt32) within a <CODE>WordFrame</CODE> to store | |
* and mutate a "compound state" as a 64-bit long. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package netflix; | |
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import com.typestruct.BaseException; | |
import com.typestruct.api.TypeStruct.Bind; | |
import com.typestruct.bind.Field; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example.type; | |
import java.text.ParseException; | |
import java.util.Date; | |
import java.util.concurrent.TimeUnit; | |
import com.typestruct.bind.BaseBinBinding; | |
import com.typestruct.bind.BinBinding; | |
import com.typestruct.bind.BindingException; | |
import com.typestruct.bind.BindingRangeException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.typestruct.api; | |
import com.typestruct.api.TypeStruct.Bind; | |
import com.typestruct.api.TypeStruct.Bind.Modifier; | |
import com.typestruct.struct.StructDef; | |
public class StructDefPrimitivesExample_NoComments { | |
static StructDef struct = TypeStruct.def("Struct Primitives", | |
Bind.byte8("byteField"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.typestruct.api; | |
import com.typestruct.api.TypeStruct.Bind; | |
import com.typestruct.api.TypeStruct.Bind.Modifier; | |
import com.typestruct.struct.StructDef; | |
import com.typestruct.struct.StructField; | |
/** | |
* Example Illustrating the definition of a multi-word <CODE>StructDef</CODE> containing: | |
* <UL> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example.type; | |
import java.text.ParseException; | |
import java.util.Arrays; | |
import java.util.Date; | |
import java.util.concurrent.TimeUnit; | |
import com.typestruct.bind.BinBinding; | |
import com.typestruct.bind.BindingException; | |
import com.typestruct.bind.MemberBinding; |
NewerOlder